Commit fe69230f authored by Zhengchao Shao's avatar Zhengchao Shao Committed by Paolo Abeni

caif: fix memory leak in cfctrl_linkup_request()

When linktype is unknown or kzalloc failed in cfctrl_linkup_request(),
pkt is not released. Add release process to error path.

Fixes: b482cd20 ("net-caif: add CAIF core protocol stack")
Fixes: 8d545c8f ("caif: Disconnect without waiting for response")
Signed-off-by: default avatarZhengchao Shao <shaozhengchao@huawei.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Link: https://lore.kernel.org/r/20230104065146.1153009-1-shaozhengchao@huawei.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 1ac88557
...@@ -269,11 +269,15 @@ int cfctrl_linkup_request(struct cflayer *layer, ...@@ -269,11 +269,15 @@ int cfctrl_linkup_request(struct cflayer *layer,
default: default:
pr_warn("Request setup of bad link type = %d\n", pr_warn("Request setup of bad link type = %d\n",
param->linktype); param->linktype);
cfpkt_destroy(pkt);
return -EINVAL; return -EINVAL;
} }
req = kzalloc(sizeof(*req), GFP_KERNEL); req = kzalloc(sizeof(*req), GFP_KERNEL);
if (!req) if (!req) {
cfpkt_destroy(pkt);
return -ENOMEM; return -ENOMEM;
}
req->client_layer = user_layer; req->client_layer = user_layer;
req->cmd = CFCTRL_CMD_LINK_SETUP; req->cmd = CFCTRL_CMD_LINK_SETUP;
req->param = *param; req->param = *param;
......
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