Skip to content

Commit

Permalink
caif: fix memory leak in cfctrl_linkup_request()
Browse files Browse the repository at this point in the history
When linktype is unknown or kzalloc failed in cfctrl_linkup_request(),
pkt is not released. Add release process to error path.

Fixes: b482cd2 ("net-caif: add CAIF core protocol stack")
Fixes: 8d545c8 ("caif: Disconnect without waiting for response")
Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20230104065146.1153009-1-shaozhengchao@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Zhengchao Shao authored and Paolo Abeni committed Jan 5, 2023
1 parent 1ac8855 commit fe69230
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/caif/cfctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,15 @@ int cfctrl_linkup_request(struct cflayer *layer,
default:
pr_warn("Request setup of bad link type = %d\n",
param->linktype);
cfpkt_destroy(pkt);
return -EINVAL;
}
req = kzalloc(sizeof(*req), GFP_KERNEL);
if (!req)
if (!req) {
cfpkt_destroy(pkt);
return -ENOMEM;
}

req->client_layer = user_layer;
req->cmd = CFCTRL_CMD_LINK_SETUP;
req->param = *param;
Expand Down

0 comments on commit fe69230

Please sign in to comment.