From: Riyan Dhiman Date: Sun, 1 Sep 2024 18:22:44 +0000 (+0530) Subject: mmc: core: Convert simple_stroul to kstroul X-Git-Tag: v6.12-rc1~158^2~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6f25e5deca7739a27462ef26fb5c07cfb926c4e4;p=thirdparty%2Fkernel%2Flinux.git 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 Link: https://lore.kernel.org/r/20240901182244.45543-1-riyandhiman14@gmail.com Signed-off-by: Ulf Hansson --- diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 2ff053f2be112..f58bea534004c 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -353,10 +353,10 @@ static ssize_t force_ro_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { int ret; - char *end; struct mmc_blk_data *md = mmc_blk_get(dev_to_disk(dev)); - unsigned long set = simple_strtoul(buf, &end, 0); - if (end == buf) { + unsigned long set; + + if (kstrtoul(buf, 0, &set)) { ret = -EINVAL; goto out; }