Skip to content

Commit fe69230

Browse files
zhengchaoshaoPaolo Abeni
authored andcommitted
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: b482cd2 ("net-caif: add CAIF core protocol stack") Fixes: 8d545c8 ("caif: Disconnect without waiting for response") Signed-off-by: Zhengchao Shao <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 1ac8855 commit fe69230

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)