Skip to content

Commit

Permalink
md/raid5: cap worker count
Browse files Browse the repository at this point in the history
static checker reports a potential integer overflow. Cap the worker count to
avoid the overflow.

Reported:-by: Dan Carpenter <[email protected]>
Signed-off-by: Shaohua Li <[email protected]>
  • Loading branch information
shligit committed Sep 28, 2017
1 parent c4d6a1b commit 7d5d7b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -6575,14 +6575,17 @@ static ssize_t
raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len)
{
struct r5conf *conf;
unsigned long new;
unsigned int new;
int err;
struct r5worker_group *new_groups, *old_groups;
int group_cnt, worker_cnt_per_group;

if (len >= PAGE_SIZE)
return -EINVAL;
if (kstrtoul(page, 10, &new))
if (kstrtouint(page, 10, &new))
return -EINVAL;
/* 8192 should be big enough */
if (new > 8192)
return -EINVAL;

err = mddev_lock(mddev);
Expand Down

0 comments on commit 7d5d7b5

Please sign in to comment.