linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] scsi: ufs: fix potential memory leak
@ 2016-06-07 23:22 Tiezhu Yang
  0 siblings, 0 replies; only message in thread
From: Tiezhu Yang @ 2016-06-07 23:22 UTC (permalink / raw)
  To: martin.petersen; +Cc: linux-scsi, linux-kernel

If the function ufshcd_parse_clock_info returns an error, the memory clkfreq
allocated by devm_kzalloc will be freed at that time. But when the function
ufshcd_parse_clock_info returns 0 on success, there exists potential memory
leak, this patch fixes it.

Signed-off-by: Tiezhu Yang <kernelpatch@126.com>
---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index db53f38..83f757f 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -122,6 +122,10 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 				clki->min_freq, clki->max_freq, clki->name);
 		list_add_tail(&clki->list, &hba->clk_list_head);
 	}
+
+	devm_kfree(dev, clkfreq);
+	clkfreq = NULL;
+
 out:
 	return ret;
 }
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-07 23:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-07 23:22 [PATCH v2] scsi: ufs: fix potential memory leak Tiezhu Yang

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).