[Drbd-dev] [patch] drbd: potential null dereference

Dan Carpenter error27 at gmail.com
Sat Mar 27 15:59:50 CET 2010


If "e" is NULL then "bm_ext" would be NULL too.

Signed-off-by: Dan Carpenter <error27 at gmail.com>
---
Found by static analysis and compile tested only.  Sorry.  :/

diff --git a/drivers/block/drbd/drbd_actlog.c b/drivers/block/drbd/drbd_actlog.c
index 17956ff..b68b778 100644
--- a/drivers/block/drbd/drbd_actlog.c
+++ b/drivers/block/drbd/drbd_actlog.c
@@ -1328,7 +1328,7 @@ int drbd_rs_del_all(struct drbd_conf *mdev)
 		for (i = 0; i < mdev->resync->nr_elements; i++) {
 			e = lc_element_by_index(mdev->resync, i);
 			bm_ext = e ? lc_entry(e, struct bm_extent, lce) : NULL;
-			if (bm_ext->lce.lc_number == LC_FREE)
+			if (!bm_ext || bm_ext->lce.lc_number == LC_FREE)
 				continue;
 			if (bm_ext->lce.lc_number == mdev->resync_wenr) {
 				dev_info(DEV, "dropping %u in drbd_rs_del_all, apparently"


More information about the drbd-dev mailing list