oslib: Fix blkzoned_get_max_open_zones()
authorDamien Le Moal <damien.lemoal@wdc.com>
Wed, 1 Sep 2021 06:41:53 +0000 (15:41 +0900)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Sep 2021 02:56:19 +0000 (20:56 -0600)
commitf3463241727215e228a60dc3b9a1ba2996f149a1
tree6f1b87242fbe7b16e4da420b1fbfc8c3a14831fb
parent4f2152278e0b3c35ded02fb3e6fb550eab7bedcd
oslib: Fix blkzoned_get_max_open_zones()

When the kernel does not have the sysfs atttribute file
queue/max_open_zones, blkzoned_get_max_open_zones() returns success
without initializing the max_open_zones value to 0 to indicate to the
caller (zbd_get_max_open_zones() in zbd.c) that the device limit is
unknown. If the max_open_zones variable in zbd_get_max_open_zones() is
not already 0 (depending on the memory status), the missing
initialization in blkzoned_get_max_open_zones() can cause errors or
misbehavior as an incorrect, random, limit may be used.

Fix this by always initializing max_open_zones to 0 when the
max_open_zones sysfs attribute file does not exist.

Reported-by: Bao-Hua Li <baohua.li@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
oslib/linux-blkzoned.c