Commit 1d59857e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarKeith Busch <kbusch@kernel.org>
Reviewed-by: default avatarChaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Reviewed-by: default avatarKanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20240613084839.1044015-9-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 1366251a
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment