linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: fix potential null pointer dereference
@ 2017-05-23 22:13 Gustavo A. R. Silva
  0 siblings, 0 replies; only message in thread
From: Gustavo A. R. Silva @ 2017-05-23 22:13 UTC (permalink / raw)
  To: Josef Bacik; +Cc: linux-block, nbd-general, linux-kernel, Gustavo A. R. Silva

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
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/block/nbd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 9a7bb2c..6006de5 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -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) {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-23 22:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-23 22:13 [PATCH] block: fix potential null pointer dereference Gustavo A. R. Silva

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).