diff mbox series

[net] caif: fix memory leak in cfctrl_linkup_request()

Message ID 20230104065146.1153009-1-shaozhengchao@huawei.com (mailing list archive)
State Accepted
Commit fe69230f05897b3de758427b574fc98025dfc907
Delegated to: Netdev Maintainers
Headers show
Series [net] caif: fix memory leak in cfctrl_linkup_request() | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 4 this patch: 4
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Jan. 4, 2023, 6:51 a.m. UTC
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>
---
 net/caif/cfctrl.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Jiri Pirko Jan. 4, 2023, 5:25 p.m. UTC | #1
Wed, Jan 04, 2023 at 07:51:46AM CET, shaozhengchao@huawei.com wrote:
>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>
patchwork-bot+netdevbpf@kernel.org Jan. 5, 2023, 9:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 4 Jan 2023 14:51:46 +0800 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net] caif: fix memory leak in cfctrl_linkup_request()
    https://git.kernel.org/netdev/net/c/fe69230f0589

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
index cc405d8c7c30..8480684f2762 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;