* [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc. @ 2020-07-29 8:18 Javed Hasan 2020-07-29 8:18 ` [PATCH 1/2] scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases Javed Hasan ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Javed Hasan @ 2020-07-29 8:18 UTC (permalink / raw) To: martin.petersen; +Cc: linux-scsi, GR-QLogic-Storage-Upstream, jhasan 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(-) -- 1.8.3.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases. 2020-07-29 8:18 [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Javed Hasan @ 2020-07-29 8:18 ` Javed Hasan 2020-07-29 8:18 ` [PATCH 2/2] scsi: fcoe: memory leak fix in fcoe_sysfs_fcf_del() Javed Hasan 2020-08-05 1:17 ` [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Martin K. Petersen 2 siblings, 0 replies; 4+ messages in thread From: Javed Hasan @ 2020-07-29 8:18 UTC (permalink / raw) To: martin.petersen; +Cc: linux-scsi, GR-QLogic-Storage-Upstream, jhasan 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. Reviewed-by: Girish Basrur <gbasrur@marvell.com> Reviewed-by: Santosh Vernekar <svernekar@marvell.com> Reviewed-by: Saurav Kashyap <skashyap@marvell.com> Reviewed-by: Shyam Sundar <ssundar@marvell.com> Signed-off-by: Javed Hasan <jhasan@marvell.com> --- drivers/scsi/libfc/fc_disc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/libfc/fc_disc.c b/drivers/scsi/libfc/fc_disc.c index 9c5f7c9..11d4350 100644 --- a/drivers/scsi/libfc/fc_disc.c +++ b/drivers/scsi/libfc/fc_disc.c @@ -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); } -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] scsi: fcoe: memory leak fix in fcoe_sysfs_fcf_del(). 2020-07-29 8:18 [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Javed Hasan 2020-07-29 8:18 ` [PATCH 1/2] scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases Javed Hasan @ 2020-07-29 8:18 ` Javed Hasan 2020-08-05 1:17 ` [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Martin K. Petersen 2 siblings, 0 replies; 4+ messages in thread From: Javed Hasan @ 2020-07-29 8:18 UTC (permalink / raw) To: martin.petersen; +Cc: linux-scsi, GR-QLogic-Storage-Upstream, jhasan 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. Reviewed-by: Girish Basrur <gbasrur@marvell.com> Reviewed-by: Santosh Vernekar <svernekar@marvell.com> Reviewed-by: Saurav Kashyap <skashyap@marvell.com> Reviewed-by: Shyam Sundar <ssundar@marvell.com> Signed-off-by: Javed Hasan <jhasan@marvell.com> --- drivers/scsi/fcoe/fcoe_ctlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index 1791a39..d2f5c6f 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c @@ -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); } /** -- 1.8.3.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc. 2020-07-29 8:18 [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Javed Hasan 2020-07-29 8:18 ` [PATCH 1/2] scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases Javed Hasan 2020-07-29 8:18 ` [PATCH 2/2] scsi: fcoe: memory leak fix in fcoe_sysfs_fcf_del() Javed Hasan @ 2020-08-05 1:17 ` Martin K. Petersen 2 siblings, 0 replies; 4+ messages in thread From: Martin K. Petersen @ 2020-08-05 1:17 UTC (permalink / raw) To: Javed Hasan; +Cc: Martin K . Petersen, linux-scsi, GR-QLogic-Storage-Upstream On Wed, 29 Jul 2020 01:18:22 -0700, Javed Hasan wrote: > 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 -- Martin K. Petersen Oracle Linux Engineering ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-05 1:19 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-07-29 8:18 [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Javed Hasan 2020-07-29 8:18 ` [PATCH 1/2] scsi: libfc: free skb in fc_disc_gpn_id_resp() for valid cases Javed Hasan 2020-07-29 8:18 ` [PATCH 2/2] scsi: fcoe: memory leak fix in fcoe_sysfs_fcf_del() Javed Hasan 2020-08-05 1:17 ` [PATCH 0/2] qedf: Memory leak fixes for fcoe and libfc Martin K. Petersen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).