Skip to content
Snippets Groups Projects
Commit 8dae54f3 authored by Ming Lei's avatar Ming Lei
Browse files

nbd: fix possible overflow on 'first_minor' in nbd_dev_add()

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2083917



commit 858f1bf6
Author: Zhang Wensheng <zhangwensheng5@huawei.com>
Date:   Sat May 21 15:37:48 2022 +0800

    nbd: fix possible overflow on 'first_minor' in nbd_dev_add()

    When 'index' is a big numbers, it may become negative which forced
    to 'int'. then 'index << part_shift' might overflow to a positive
    value that is not greater than '0xfffff', then sysfs might complains
    about duplicate creation. Because of this, move the 'index' judgment
    to the front will fix it and be better.

    Fixes: b0d9111a ("nbd: use an idr to keep track of nbd devices")
    Fixes: 940c2649 ("nbd: fix possible overflow for 'first_minor' in nbd_dev_add()")
Signed-off-by: default avatarZhang Wensheng <zhangwensheng5@huawei.com>
Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Link: https://lore.kernel.org/r/20220521073749.3146892-6-yukuai3@huawei.com


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>

Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
parent 8f336f83
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment