summaryrefslogtreecommitdiffstats
path: root/drivers/block/drbd/drbd_int.h
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2012-10-19 14:19:23 +0200
committerPhilipp Reisner <philipp.reisner@linbit.com>2012-11-09 14:11:42 +0100
commitfd0017c1243b2b9058525672b9ea13272fb51b30 (patch)
tree529e6eaef73f2ac210e12f9bc4eb8a6178e1894c /drivers/block/drbd/drbd_int.h
parentdrbd: Fix clearing of MDF_AL_DISABLED (diff)
downloadlinux-fd0017c1243b2b9058525672b9ea13272fb51b30.tar.xz
linux-fd0017c1243b2b9058525672b9ea13272fb51b30.zip
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>
Diffstat (limited to 'drivers/block/drbd/drbd_int.h')
-rw-r--r--drivers/block/drbd/drbd_int.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 32a9ab67a5f6..057ffed6eb7e 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -2318,6 +2318,11 @@ static inline void drbd_md_flush(struct drbd_conf *mdev)
{
int r;
+ if (mdev->ldev == NULL) {
+ dev_warn(DEV, "mdev->ldev == NULL in drbd_md_flush\n");
+ return;
+ }
+
if (test_bit(MD_NO_FUA, &mdev->flags))
return;