aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Hellwig <[email protected]>2024-06-13 10:48:18 +0200
committerJens Axboe <[email protected]>2024-06-14 10:20:06 -0600
commit1d59857ed2ec4d506e346859713c4325b5053da3 (patch)
treedb2c798225848d5fb12bbf64686c13ffbb4ec48d
parent1366251a794b149a132ef8423c8946b6e565a923 (diff)
block: use kstrtoul in flag_store
Use the text to integer helper that has error handling and doesn't modify the input pointer. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Keith Busch <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
-rw-r--r--block/blk-integrity.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/block/blk-integrity.c b/block/blk-integrity.c
index 24671d9f90a1..58760a6d6b22 100644
--- a/block/blk-integrity.c
+++ b/block/blk-integrity.c
@@ -247,8 +247,12 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr,
const char *page, size_t count, unsigned char flag)
{
struct blk_integrity *bi = dev_to_bi(dev);
- char *p = (char *) page;
- unsigned long val = simple_strtoul(p, &p, 10);
+ unsigned long val;
+ int err;
+
+ err = kstrtoul(page, 10, &val);
+ if (err)
+ return err;
if (val)
bi->flags |= flag;