Skip to contentSkip to conversation

block: fix potential null pointer dereference

PATCH New Gustavo A. R. Silva 1 participant 1 message May 23, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: fix potential null pointer dereference

Add null check before dereferencing pointer dev_list inside function nla_nest_end() at line 1968: nla_nest_end(reply, dev_list);

Addresses-Coverity-ID: 1408827

---
 drivers/block/nbd.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/block/nbd.c +3 -0
index 9a7bb2c..6006de5 100644
@@ -1948,6 +1948,9 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info)
 	}
 
 	dev_list = nla_nest_start(reply, NBD_ATTR_DEVICE_LIST);
+	if (!dev_list)
+		goto out;
+
 	if (index == -1) {
 		ret = idr_for_each(&nbd_index_idr, &status_cb, reply);
 		if (ret) {
Signature · 1 line
2.5.0