Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

block: mtip32xx: set error code on failure

Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188531. In function
mtip_block_initialize(), variable rv takes the return value, and its
value should be negative on errors. rv is initialized as 0 and is not
reset when the call to ida_pre_get() fails. So 0 may be returned.
The return value 0 indicates that there is no error, which may be
inconsistent with the execution status. This patch fixes the bug by
explicitly assigning -ENOMEM to rv on the branch that ida_pre_get()
fails.

Signed-off-by: Pan Bian <bianpan2016@163.com>
Signed-off-by: Jens Axboe <axboe@fb.com>

authored by

Pan Bian and committed by
Jens Axboe
5b0e34e1 d2629209

+3 -1
+3 -1
drivers/block/mtip32xx/mtip32xx.c
··· 3933 3933 3934 3934 /* Generate the disk name, implemented same as in sd.c */ 3935 3935 do { 3936 - if (!ida_pre_get(&rssd_index_ida, GFP_KERNEL)) 3936 + if (!ida_pre_get(&rssd_index_ida, GFP_KERNEL)) { 3937 + rv = -ENOMEM; 3937 3938 goto ida_get_error; 3939 + } 3938 3940 3939 3941 spin_lock(&rssd_index_lock); 3940 3942 rv = ida_get_new(&rssd_index_ida, &index);