Skip to content

Commit a65b327

Browse files
x2018martinkpetersen
authored andcommitted
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/[email protected] Reviewed-by: Bean Huo <[email protected]> Signed-off-by: Xiaoke Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent a861790 commit a65b327

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/scsi/ufs/ufshcd-pltfrm.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
9292
clki->min_freq = clkfreq[i];
9393
clki->max_freq = clkfreq[i+1];
9494
clki->name = devm_kstrdup(dev, name, GFP_KERNEL);
95+
if (!clki->name) {
96+
ret = -ENOMEM;
97+
goto out;
98+
}
99+
95100
if (!strcmp(name, "ref_clk"))
96101
clki->keep_link_active = true;
97102
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,
127132
return -ENOMEM;
128133

129134
vreg->name = devm_kstrdup(dev, name, GFP_KERNEL);
135+
if (!vreg->name)
136+
return -ENOMEM;
130137

131138
snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name);
132139
if (of_property_read_u32(np, prop_name, &vreg->max_uA)) {

0 commit comments

Comments
 (0)