qedf: Memory leak fixes for fcoe and libfc.
Subsystems (2)
cover qedf: Memory leak fixes for fcoe and libfc.
Hi Martin,
This series has fixes for memory leaks report by
KMEMLEAK tool.
Kindly apply this series to scsi-queue at your earliest convenience.
Thanks,
Javed Hasan
Javed Hasan (2):
scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases.
scsi: fcoe: memory leak fix in fcoe_sysfs_fcf_del().
drivers/scsi/fcoe/fcoe_ctlr.c | 2 +- drivers/scsi/libfc/fc_disc.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/2 scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases.
In fc_disc_gpn_id_resp(), skb is supposed to get free for all the cases (excluding PTR_ERR). But it wasn't get free in all the cases, leading to memory leak.
This fix is to execute fc_frame_free(fp) before function returns.
--- drivers/scsi/libfc/fc_disc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/scsi/libfc/fc_disc.c +10 -4
@@ -581,9 +581,13 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,if (PTR_ERR (fp) == -FC_EX_CLOSED ) goto out; -if (IS_ERR (fp)) - goto redisc; - +if (IS_ERR (fp)) { +mutex_lock (&disc->disc_mutex); +fc_disc_restart (disc); +mutex_unlock (&disc->disc_mutex); + goto out; + } + cp =fc_frame_payload_get (fp,sizeof (*cp));if (!cp) goto redisc;
@@ -609,7 +613,7 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp, new_rdata->disc_id = disc->disc_id;fc_rport_login (new_rdata); } - goto out; + goto free_fp; } rdata->disc_id = disc->disc_id;mutex_unlock (&rdata->rp_mutex);
@@ -626,6 +630,8 @@ static void fc_disc_gpn_id_resp(struct fc_seq *sp, struct fc_frame *fp,fc_disc_restart (disc);mutex_unlock (&disc->disc_mutex); } +free_fp: +fc_frame_free (fp); out:kref_put (&rdata->kref, fc_rport_destroy); }
Signature · 1 line
1.8.3.1
PATCH 2/2 scsi: fcoe: memory leak fix in fcoe_sysfs_fcf_del().
In reply to Javed Hasan In fcoe_sysfs_fcf_del(), we first deleted the fcf from the list and free it if ctlr_dev is not NULL.
This was causing the memory leak for fcf.
This fix is just to free the fcf even if ctlr_dev is NULL or not.
--- drivers/scsi/fcoe/fcoe_ctlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/fcoe/fcoe_ctlr.c +1 -1
@@ -255,9 +255,9 @@ static void fcoe_sysfs_fcf_del(struct fcoe_fcf *new)WARN_ON (!fcf_dev); new->fcf_dev =NULL ;fcoe_fcf_device_delete (fcf_dev); -kfree (new);mutex_unlock (&cdev->lock); } +kfree (new); }/**
Signature · 1 line
1.8.3.1
Martin K. Petersen
AppliedQuoted 9 lines · Javed Hasan
This series has fixes for memory leaks report by
KMEMLEAK tool.Kindly apply this series to scsi-queue at your earliest convenience.
Thanks,
Javed Hasan[...]
Applied to 5.9/scsi-queue, thanks!
[1/2] scsi: libfc: Free skb in fc_disc_gpn_id_resp() for valid cases
https://git.kernel.org/mkp/scsi/c/ec007ef40abb [2/2] scsi: fcoe: Memory leak fix in fcoe_sysfs_fcf_del() https://git.kernel.org/mkp/scsi/c/e95b4789ff43
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering