scsi: qla2xxx: Cleanup fcport memory to prevent leak
authorQuinn Tran <qtran@marvell.com>
Tue, 2 Apr 2019 21:24:29 +0000 (14:24 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 4 Apr 2019 03:45:58 +0000 (23:45 -0400)
Clean up fcport list and loopid in one place and iterate through for loop.

Signed-off-by: Quinn Tran <qtran@marvell.com>
Signed-off-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_os.c

index 61dddeee75a0a0de065cf5d997117568bcdc55dd..a16dbef7ecc97e4a26340b7d8e092e37431642fa 100644 (file)
@@ -4821,6 +4821,8 @@ qla2x00_free_fcport(fc_port_t *fcport)
 
                fcport->ct_desc.ct_sns = NULL;
        }
+       list_del(&fcport->list);
+       qla2x00_clear_loop_id(fcport);
        kfree(fcport);
 }
 
index 6671566632e0436472aa9c1cbe33b340e32818bd..11ed0168504e044051c1589c9ec5f2a0843e6445 100644 (file)
@@ -3907,11 +3907,8 @@ void qla2x00_free_fcports(struct scsi_qla_host *vha)
 {
        fc_port_t *fcport, *tfcport;
 
-       list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) {
-               list_del(&fcport->list);
-               qla2x00_clear_loop_id(fcport);
-               kfree(fcport);
-       }
+       list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list)
+               qla2x00_free_fcport(fcport);
 }
 
 static inline void