Skip to content

Commit

Permalink
iocost: don't nest spin_lock_irq in ioc_weight_write()
Browse files Browse the repository at this point in the history
This code causes a static analysis warning:

    block/blk-iocost.c:2113 ioc_weight_write() error: double lock 'irq'

We disable IRQs in blkg_conf_prep() and re-enable them in
blkg_conf_finish().  IRQ disable/enable should not be nested because
that means the IRQs will be enabled at the first unlock instead of the
second one.

Fixes: 7caa471 ("blkcg: implement blk-iocost")
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Dan Carpenter authored and Jens Axboe committed Oct 31, 2019
1 parent 6873e0b commit 41591a5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions block/blk-iocost.c
Original file line number Diff line number Diff line change
Expand Up @@ -2110,10 +2110,10 @@ static ssize_t ioc_weight_write(struct kernfs_open_file *of, char *buf,
goto einval;
}

spin_lock_irq(&iocg->ioc->lock);
spin_lock(&iocg->ioc->lock);
iocg->cfg_weight = v;
weight_updated(iocg);
spin_unlock_irq(&iocg->ioc->lock);
spin_unlock(&iocg->ioc->lock);

blkg_conf_finish(&ctx);
return nbytes;
Expand Down

0 comments on commit 41591a5

Please sign in to comment.