Skip to content

Commit dc1bc90

Browse files
zhengchaoshaogregkh
authored andcommitted
caif: fix memory leak in cfctrl_linkup_request()
[ Upstream commit fe69230 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bce3680 commit dc1bc90

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/caif/cfctrl.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,15 @@ int cfctrl_linkup_request(struct cflayer *layer,
269269
default:
270270
pr_warn("Request setup of bad link type = %d\n",
271271
param->linktype);
272+
cfpkt_destroy(pkt);
272273
return -EINVAL;
273274
}
274275
req = kzalloc(sizeof(*req), GFP_KERNEL);
275-
if (!req)
276+
if (!req) {
277+
cfpkt_destroy(pkt);
276278
return -ENOMEM;
279+
}
280+
277281
req->client_layer = user_layer;
278282
req->cmd = CFCTRL_CMD_LINK_SETUP;
279283
req->param = *param;

0 commit comments

Comments
 (0)