Commit a65b3274 authored by Xiaoke Wang's avatar Xiaoke Wang Committed by Martin K. Petersen

scsi: ufs: ufshcd-pltfrm: Check the return value of devm_kstrdup()

devm_kstrdup() returns pointer to allocated string on success, NULL on
failure. So it is better to check the return value of it.

Link: https://lore.kernel.org/r/tencent_4257E15D4A94FF9020DDCC4BB9B21C041408@qq.comReviewed-by: default avatarBean Huo <beanhuo@micron.com>
Signed-off-by: default avatarXiaoke Wang <xkernel.wang@foxmail.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent a861790a
...@@ -92,6 +92,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba) ...@@ -92,6 +92,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
clki->min_freq = clkfreq[i]; clki->min_freq = clkfreq[i];
clki->max_freq = clkfreq[i+1]; clki->max_freq = clkfreq[i+1];
clki->name = devm_kstrdup(dev, name, GFP_KERNEL); clki->name = devm_kstrdup(dev, name, GFP_KERNEL);
if (!clki->name) {
ret = -ENOMEM;
goto out;
}
if (!strcmp(name, "ref_clk")) if (!strcmp(name, "ref_clk"))
clki->keep_link_active = true; clki->keep_link_active = true;
dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz", 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, ...@@ -127,6 +132,8 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name,
return -ENOMEM; return -ENOMEM;
vreg->name = devm_kstrdup(dev, name, GFP_KERNEL); vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
if (!vreg->name)
return -ENOMEM;
snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name); snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
if (of_property_read_u32(np, prop_name, &vreg->max_uA)) { if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment