Skip to content

Commit 1d59857

Browse files
Christoph Hellwigaxboe
authored andcommitted
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]>
1 parent 1366251 commit 1d59857

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

block/blk-integrity.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,12 @@ static ssize_t flag_store(struct device *dev, struct device_attribute *attr,
247247
const char *page, size_t count, unsigned char flag)
248248
{
249249
struct blk_integrity *bi = dev_to_bi(dev);
250-
char *p = (char *) page;
251-
unsigned long val = simple_strtoul(p, &p, 10);
250+
unsigned long val;
251+
int err;
252+
253+
err = kstrtoul(page, 10, &val);
254+
if (err)
255+
return err;
252256

253257
if (val)
254258
bi->flags |= flag;

0 commit comments

Comments
 (0)