]> git.baikalelectronics.ru Git - kernel.git/commit
block/rnbd: Ensure err is always initialized in process_rdma
authorNathan Chancellor <natechancellor@gmail.com>
Tue, 18 Aug 2020 06:49:25 +0000 (23:49 -0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 21 Aug 2020 23:09:11 +0000 (17:09 -0600)
commitc04862664347562c26050ddb0c239bb2d723e9fc
tree664152b89d4e4e6ca9c1b6379ca522a5704867a6
parentdfe393feac78053d373877e2ded6ad3885c16c7b
block/rnbd: Ensure err is always initialized in process_rdma

Clang warns:

drivers/block/rnbd/rnbd-srv.c:150:6: warning: variable 'err' is used
uninitialized whenever 'if' condition is true
[-Wsometimes-uninitialized]
        if (IS_ERR(bio)) {
            ^~~~~~~~~~~
drivers/block/rnbd/rnbd-srv.c:177:9: note: uninitialized use occurs here
        return err;
               ^~~
drivers/block/rnbd/rnbd-srv.c:150:2: note: remove the 'if' if its
condition is always false
        if (IS_ERR(bio)) {
        ^~~~~~~~~~~~~~~~~~
drivers/block/rnbd/rnbd-srv.c:126:9: note: initialize the variable 'err'
to silence this warning
        int err;
               ^
                = 0
1 warning generated.

err is indeed uninitialized when this statement is taken. Ensure that it
is assigned the error value of bio before jumping to the error handling
label.

Fixes: 0264a9d6143e ("rnbd: remove rnbd_dev_submit_io")
Reported-by: Brooke Basile <brookebasile@gmail.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/1134
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/rnbd/rnbd-srv.c