From: Pavel Skripkin <paskripkin@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, sjur.brandeland@stericsson.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Pavel Skripkin <paskripkin@gmail.com>,
stable@vger.kernel.org,
syzbot+7ec324747ce876a29db6@syzkaller.appspotmail.com
Subject: [PATCH 3/4] net: caif: fix memory leak in caif_device_notify
Date: Thu, 3 Jun 2021 19:39:11 +0300 [thread overview]
Message-ID: <fcddc06204f166d2ef0d75360b89f6f629a3b0c4.1622737854.git.paskripkin@gmail.com> (raw)
In-Reply-To: <cover.1622737854.git.paskripkin@gmail.com>
In case of caif_enroll_dev() fail, allocated
link_support won't be assigned to the corresponding
structure. So simply free allocated pointer in case
of error
Fixes: 7c18d2205ea7 ("caif: Restructure how link caif link layer enroll")
Cc: stable@vger.kernel.org
Reported-and-tested-by: syzbot+7ec324747ce876a29db6@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
net/caif/caif_dev.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c
index fffbe41440b3..440139706130 100644
--- a/net/caif/caif_dev.c
+++ b/net/caif/caif_dev.c
@@ -370,6 +370,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
struct cflayer *layer, *link_support;
int head_room = 0;
struct caif_device_entry_list *caifdevs;
+ int res;
cfg = get_cfcnfg(dev_net(dev));
caifdevs = caif_device_list(dev_net(dev));
@@ -395,8 +396,10 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
break;
}
}
- caif_enroll_dev(dev, caifdev, link_support, head_room,
+ res = caif_enroll_dev(dev, caifdev, link_support, head_room,
&layer, NULL);
+ if (res)
+ cfserl_release(link_support);
caifdev->flowctrl = dev_flowctrl;
break;
--
2.31.1
next prev parent reply other threads:[~2021-06-03 16:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-03 16:37 [PATCH 0/4] net: caif: fix 2 memory leaks Pavel Skripkin
2021-06-03 16:38 ` [PATCH 1/4] net: caif: added cfserl_release function Pavel Skripkin
2021-06-03 16:38 ` [PATCH 2/4] net: caif: add proper error handling Pavel Skripkin
2021-06-03 16:39 ` Pavel Skripkin [this message]
2021-06-03 16:42 ` [PATCH 3/4] net: caif: fix memory leak in caif_device_notify Pavel Skripkin
2021-06-03 16:39 ` [PATCH 4/4] net: caif: fix memory leak in cfusbl_device_notify Pavel Skripkin
2021-06-03 22:20 ` [PATCH 0/4] net: caif: fix 2 memory leaks patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fcddc06204f166d2ef0d75360b89f6f629a3b0c4.1622737854.git.paskripkin@gmail.com \
--to=paskripkin@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sjur.brandeland@stericsson.com \
--cc=stable@vger.kernel.org \
--cc=syzbot+7ec324747ce876a29db6@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).