Skip to content

Commit

Permalink
block: use kstrtoul in flag_store
Browse files Browse the repository at this point in the history
Use the text to integer helper that has error handling and doesn't modify
the input pointer.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Kanchan Joshi <joshi.k@samsung.com>
Link: https://lore.kernel.org/r/20240613084839.1044015-9-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Jun 14, 2024
1 parent 1366251 commit 1d59857
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions block/blk-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1d59857

Please sign in to comment.