diff options
author | Zhengchao Shao <shaozhengchao@huawei.com> | 2023-01-04 14:51:46 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-01-18 09:26:41 +0100 |
commit | badea57569db04b010e922e29a7aaf40a979a70b (patch) | |
tree | 30c68ef2be6f66674dfc4c7bf3fdc37263fa6717 /net/caif | |
parent | 55782f6d63a5a3dd3b84c1e0627738fc5b146b4e (diff) | |
download | linux-stable-badea57569db04b010e922e29a7aaf40a979a70b.tar.gz linux-stable-badea57569db04b010e922e29a7aaf40a979a70b.tar.bz2 linux-stable-badea57569db04b010e922e29a7aaf40a979a70b.zip |
caif: fix memory leak in cfctrl_linkup_request()
[ Upstream commit fe69230f05897b3de758427b574fc98025dfc907 ]
When linktype is unknown or kzalloc failed in cfctrl_linkup_request(),
pkt is not released. Add release process to error path.
Fixes: b482cd2053e3 ("net-caif: add CAIF core protocol stack")
Fixes: 8d545c8f958f ("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>
Diffstat (limited to 'net/caif')
-rw-r--r-- | net/caif/cfctrl.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c index 4dc82e9a855d..7af9439a08c3 100644 --- a/net/caif/cfctrl.c +++ b/net/caif/cfctrl.c @@ -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; |