drbd: fix regression: potential NULL pointer dereference
authorPhilipp Reisner <philipp.reisner@linbit.com>
Fri, 19 Oct 2012 12:19:23 +0000 (14:19 +0200)
committerPhilipp Reisner <philipp.reisner@linbit.com>
Fri, 9 Nov 2012 13:11:42 +0000 (14:11 +0100)
commitfd0017c1243b2b9058525672b9ea13272fb51b30
tree529e6eaef73f2ac210e12f9bc4eb8a6178e1894c
parent4035e4c2ebeb6ac1acbf4e5dd8a759fcf93ff8da
drbd: fix regression: potential NULL pointer dereference

recent commit
    drbd: always write bitmap on detach
introduced a bitmap writeout during detach,
which obviously needs some meta data device to write to.

Unfortunately, that same error path may be taken if we fail to attach,
e.g. due to UUID mismatch, after we changed state to D_ATTACHING,
but before the lower level device pointer is even assigned.

We need to test for presence of mdev->ldev.

Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
drivers/block/drbd/drbd_int.h
drivers/block/drbd/drbd_main.c