Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1416725 > unrolled thread

[PATCH v2] scsi: ufs: fix potential memory leak

Started by"Tiezhu Yang" <kernelpatch@126.com>
First post2016-06-08 01:30 +0200
Last post2016-06-08 01:30 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] scsi: ufs: fix potential memory leak "Tiezhu Yang" <kernelpatch@126.com> - 2016-06-08 01:30 +0200

#1416725 — [PATCH v2] scsi: ufs: fix potential memory leak

From"Tiezhu Yang" <kernelpatch@126.com>
Date2016-06-08 01:30 +0200
Subject[PATCH v2] scsi: ufs: fix potential memory leak
Message-ID<rHyBz-Dr-3@gated-at.bofh.it>
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

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web