drbd: abort drbd_start_resync if there is no connection
authorRoland Kammerer <roland.kammerer@linbit.com>
Tue, 29 Aug 2017 08:20:47 +0000 (10:20 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 29 Aug 2017 21:34:46 +0000 (15:34 -0600)
This was found by a static analysis tool. While highly unlikely, be sure
to return without dereferencing the NULL pointer.

Reported-by: Shaobo <shaobo@cs.utah.edu>
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/drbd/drbd_worker.c

index f0717a97a42a62c759101c9d562bee7bf0fa6ad1..03471b3fce86c7660617f7871bf63c78a3f6c585 100644 (file)
@@ -1756,6 +1756,11 @@ void drbd_start_resync(struct drbd_device *device, enum drbd_conns side)
                return;
        }
 
+       if (!connection) {
+               drbd_err(device, "No connection to peer, aborting!\n");
+               return;
+       }
+
        if (!test_bit(B_RS_H_DONE, &device->flags)) {
                if (side == C_SYNC_TARGET) {
                        /* Since application IO was locked out during C_WF_BITMAP_T and