[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_4257E15D4A94FF9020DDCC4BB9B21C041408@qq.com>
Date: Sun, 16 Jan 2022 11:06:49 +0800
From: xkernel.wang@...mail.com
To: bvanassche@....org, jejb@...ux.ibm.com, martin.petersen@...cle.com
Cc: alim.akhtar@...sung.com, avri.altman@....com,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH v2] scsi: ufs: ufshcd-pltfrm: check the return value of devm_kstrdup()
From: Xiaoke Wang <xkernel.wang@...mail.com>
devm_kstrdup() returns pointer to allocated string on success,
NULL on failure. So it is better to check the return value of it.
Signed-off-by: Xiaoke Wang <xkernel.wang@...mail.com>
---
Changelogs:
1. Use my official name.
2. Synchronize with the latest source code(kstrdup -> devm_kstrdup).
3. Clear up useless code(devm_kfree).
drivers/scsi/ufs/ufshcd-pltfrm.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c
index d35b892..186540a 100644
--- a/drivers/scsi/ufs/ufshcd-pltfrm.c
+++ b/drivers/scsi/ufs/ufshcd-pltfrm.c
@@ -92,6 +92,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
clki->min_freq = clkfreq[i];
clki->max_freq = clkfreq[i+1];
clki->name = devm_kstrdup(dev, name, GFP_KERNEL);
+ if (!clki->name) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
if (!strcmp(name, "ref_clk"))
clki->keep_link_active = true;
dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz",
@@ -127,6 +132,8 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
return -ENOMEM;
vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
+ if (!vreg->name)
+ return -ENOMEM;
snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
--
Powered by blists - more mailing lists