* [PATCH] ll_map: Fix descriptor leak in ll_link_get()
@ 2024-02-07 20:32 Maks Mishin
2024-02-08 13:33 ` Donald Hunter
2024-02-08 16:56 ` Stephen Hemminger
0 siblings, 2 replies; 3+ messages in thread
From: Maks Mishin @ 2024-02-07 20:32 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: Maks Mishin, netdev
Found by RASU JSC
Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
---
lib/ll_map.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/ll_map.c b/lib/ll_map.c
index 8970c20f..711708a5 100644
--- a/lib/ll_map.c
+++ b/lib/ll_map.c
@@ -278,8 +278,10 @@ static int ll_link_get(const char *name, int index)
struct nlmsghdr *answer;
int rc = 0;
- if (rtnl_open(&rth, 0) < 0)
+ if (rtnl_open(&rth, 0) < 0) {
+ rtnl_close(&rth);
return 0;
+ }
addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filt_mask);
if (name)
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ll_map: Fix descriptor leak in ll_link_get()
2024-02-07 20:32 [PATCH] ll_map: Fix descriptor leak in ll_link_get() Maks Mishin
@ 2024-02-08 13:33 ` Donald Hunter
2024-02-08 16:56 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Donald Hunter @ 2024-02-08 13:33 UTC (permalink / raw)
To: Maks Mishin; +Cc: Stephen Hemminger, netdev
Maks Mishin <maks.mishinfz@gmail.com> writes:
> Found by RASU JSC
>
> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
> lib/ll_map.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/ll_map.c b/lib/ll_map.c
> index 8970c20f..711708a5 100644
> --- a/lib/ll_map.c
> +++ b/lib/ll_map.c
> @@ -278,8 +278,10 @@ static int ll_link_get(const char *name, int index)
> struct nlmsghdr *answer;
> int rc = 0;
>
> - if (rtnl_open(&rth, 0) < 0)
> + if (rtnl_open(&rth, 0) < 0) {
> + rtnl_close(&rth);
There's no need to call rtnl_close() if the call to rtnl_open() just
failed.
> return 0;
> + }
>
> addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filt_mask);
> if (name)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ll_map: Fix descriptor leak in ll_link_get()
2024-02-07 20:32 [PATCH] ll_map: Fix descriptor leak in ll_link_get() Maks Mishin
2024-02-08 13:33 ` Donald Hunter
@ 2024-02-08 16:56 ` Stephen Hemminger
1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2024-02-08 16:56 UTC (permalink / raw)
To: Maks Mishin; +Cc: netdev
On Wed, 7 Feb 2024 23:32:39 +0300
Maks Mishin <maks.mishinfz@gmail.com> wrote:
> Found by RASU JSC
>
> Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
> ---
> lib/ll_map.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/ll_map.c b/lib/ll_map.c
> index 8970c20f..711708a5 100644
> --- a/lib/ll_map.c
> +++ b/lib/ll_map.c
> @@ -278,8 +278,10 @@ static int ll_link_get(const char *name, int index)
> struct nlmsghdr *answer;
> int rc = 0;
>
> - if (rtnl_open(&rth, 0) < 0)
> + if (rtnl_open(&rth, 0) < 0) {
> + rtnl_close(&rth);
> return 0;
> + }
>
> addattr32(&req.n, sizeof(req), IFLA_EXT_MASK, filt_mask);
> if (name)
Same as previous patch.
This doesn't make sense, the error path in rtnl_open cleans up
itself. Do you have a reproducer or is this just some static analyzer?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-08 16:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-07 20:32 [PATCH] ll_map: Fix descriptor leak in ll_link_get() Maks Mishin
2024-02-08 13:33 ` Donald Hunter
2024-02-08 16:56 ` Stephen Hemminger
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).