Skip to contentSkip to conversation

scsi: ufs: fix potential memory leak

PATCH New Tiezhu Yang 1 participant 1 message Jun 7, 2016 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scsi: ufs: fix potential memory leak

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.

---
 drivers/scsi/ufs/ufshcd-pltfrm.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/scsi/ufs/ufshcd-pltfrm.c +4 -0
index db53f38..83f757f 100644
@@ -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;
 }
Signature · 1 line
1.8.3.1