Skip to content

Commit 6f25e5d

Browse files
Ryand1234storulf
authored andcommitted
mmc: core: Convert simple_stroul to kstroul
simple_strtoul() is obsolete and lacks proper error handling, making it unsafe for converting strings to unsigned long values. Replace it with kstrtoul(), which provides robust error checking and better safety. This change improves the reliability of the string-to-integer conversion and aligns with current kernel coding standards. Error handling is added to catch conversion failures, returning -EINVAL when input is invalid. Issue reported by checkpatch: - WARNING: simple_strtoul is obsolete, use kstrtoul instead Signed-off-by: Riyan Dhiman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent d2253bf commit 6f25e5d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/mmc/core/block.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,10 @@ static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr,
353353
const char *buf, size_t count)
354354
{
355355
int ret;
356-
char *end;
357356
struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev));
358-
unsigned long set = simple_strtoul(buf, &end, 0);
359-
if (end == buf) {
357+
unsigned long set;
358+
359+
if (kstrtoul(buf, 0, &set)) {
360360
ret = -EINVAL;
361361
goto out;
362362
}

0 commit comments

Comments
 (0)