diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index d379a047d427..d12e9f1721c8 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -2344,6 +2344,12 @@ static int nbd_genl_status(struct sk_buff *skb, struct genl_info *info) } dev_list = nla_nest_start_noflag(reply, NBD_ATTR_DEVICE_LIST); + if (!dev_list) { + nlmsg_free(reply); + ret = -EMSGSIZE; + goto out; + } + if (index == -1) { ret = idr_for_each(&nbd_index_idr, &status_cb, reply); if (ret) {