Commit 48f40b96 authored by Aditya Pakki's avatar Aditya Pakki Committed by Mika Westerberg

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: default avatarAditya Pakki <pakki001@umn.edu>
Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
parent 9aabb685
...@@ -526,7 +526,7 @@ static void tb_xdp_handle_request(struct work_struct *work) ...@@ -526,7 +526,7 @@ static void tb_xdp_handle_request(struct work_struct *work)
kfree(xw); kfree(xw);
} }
static void static bool
tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr, tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr,
size_t size) size_t size)
{ {
...@@ -534,13 +534,18 @@ tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr, ...@@ -534,13 +534,18 @@ tb_xdp_schedule_request(struct tb *tb, const struct tb_xdp_header *hdr,
xw = kmalloc(sizeof(*xw), GFP_KERNEL); xw = kmalloc(sizeof(*xw), GFP_KERNEL);
if (!xw) if (!xw)
return; return false;
INIT_WORK(&xw->work, tb_xdp_handle_request); INIT_WORK(&xw->work, tb_xdp_handle_request);
xw->pkg = kmemdup(hdr, size, GFP_KERNEL); xw->pkg = kmemdup(hdr, size, GFP_KERNEL);
if (!xw->pkg) {
kfree(xw);
return false;
}
xw->tb = tb; xw->tb = tb;
queue_work(tb->wq, &xw->work); 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, ...@@ -1422,10 +1427,8 @@ bool tb_xdomain_handle_request(struct tb *tb, enum tb_cfg_pkg_type type,
* handlers in turn. * handlers in turn.
*/ */
if (uuid_equal(&hdr->uuid, &tb_xdp_uuid)) { if (uuid_equal(&hdr->uuid, &tb_xdp_uuid)) {
if (type == TB_CFG_PKG_XDOMAIN_REQ) { if (type == TB_CFG_PKG_XDOMAIN_REQ)
tb_xdp_schedule_request(tb, hdr, size); return tb_xdp_schedule_request(tb, hdr, size);
return true;
}
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment