lkml.org 
[lkml]   [2019]   [Mar]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] block: nbd: fix a missing check for nla_nest_start
Date
nla_nest_start may fail and thus deserves a check.

The fix inserts such a check and exits gracefully in case it
fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/block/nbd.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7c9a949e876b..810c8c20b142 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2099,6 +2099,10 @@ 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) {
+ nlmsg_free(reply);
+ goto out;
+ }
if (index == -1) {
ret = idr_for_each(&nbd_index_idr, &status_cb, reply);
if (ret) {
--
2.17.1
\
 
 \ /
  Last update: 2019-03-15 07:33    [W:0.038 / U:24.284 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site