Issue:
Memory leak can happen when diag buffer is released but not
unregistered(where buffer is deallocated) by the user.
since during module unload time driver is not deallocating
the buffer if the buffer is in released state.

Fix:
Deallocate the diag buffer during module unload time without
any diag buffer status checks.

Signed-off-by: Sreekanth Reddy <sreekanth.re...@broadcom.com>
---
 drivers/scsi/mpt3sas/mpt3sas_ctl.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c 
b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
index a195cae..9b37a32 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c
@@ -3773,12 +3773,6 @@ mpt3sas_ctl_exit(ushort hbas_to_enumerate)
                for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
                        if (!ioc->diag_buffer[i])
                                continue;
-                       if (!(ioc->diag_buffer_status[i] &
-                           MPT3_DIAG_BUFFER_IS_REGISTERED))
-                               continue;
-                       if ((ioc->diag_buffer_status[i] &
-                           MPT3_DIAG_BUFFER_IS_RELEASED))
-                               continue;
                        dma_free_coherent(&ioc->pdev->dev,
                                          ioc->diag_buffer_sz[i],
                                          ioc->diag_buffer[i],
-- 
1.8.3.1

Reply via email to