diff options
author | Aditya Pakki <pakki001@umn.edu> | 2019-03-20 19:47:20 +0300 |
---|---|---|
committer | Mika Westerberg <mika.westerberg@linux.intel.com> | 2019-03-22 13:27:44 +0300 |
commit | 48f40b96de2c790eac6114e3e879a48fe9f89349 (patch) | |
tree | 9bee318598daaab1af8e2c7c5d9bde61fa75328e /drivers/thunderbolt | |
parent | 9aabb68568b473bf2f0b179d053b403961e42e4d (diff) | |
download | linux-48f40b96de2c790eac6114e3e879a48fe9f89349.tar.xz |
thunderbolt: xdomain: Fix to check return value of kmemdup
kmemdup can fail and return a NULL pointer. The patch modifies the
signature of tb_xdp_schedule_request and passes the failure error upstream.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r-- | drivers/thunderbolt/xdomain.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/thunderbolt/xdomain.c b/drivers/thunderbolt/xdomain.c index e0642dcb8b9b..e2fc4543142d 100644 --- a/drivers/thunderbolt/xdomain.c +++ b/drivers/thunderbolt/xdomain.c @@ -526,7 +526,7 @@ out: kfree(xw); } -static void +static bool tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr, size_t size) { @@ -534,13 +534,18 @@ tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr, xw = kmalloc(sizeof(*xw), GFP_KERNEL); if (!xw) - return; + return false; INIT_WORK(&xw->work, tb_xdp_handle_request); xw->pkg = kmemdup(hdr, size, GFP_KERNEL); + if (!xw->pkg) { + kfree(xw); + return false; + } xw->tb = tb; queue_work(tb->wq, &xw->work); + return true; } /** @@ -1422,10 +1427,8 @@ bool tb_xdomain_handle_request(struct tb *tb, enum tb_cfg_pkg_type type, * handlers in turn. */ if (uuid_equal(&hdr->uuid, &tb_xdp_uuid)) { - if (type == TB_CFG_PKG_XDOMAIN_REQ) { - tb_xdp_schedule_request(tb, hdr, size); - return true; - } + if (type == TB_CFG_PKG_XDOMAIN_REQ) + return tb_xdp_schedule_request(tb, hdr, size); return false; } |