Message ID | 20240207203239.10851-1-maks.mishinFZ@gmail.com (mailing list archive) |
---|---|
State | Rejected |
Delegated to: | Stephen Hemminger |
Headers | show |
Series | ll_map: Fix descriptor leak in ll_link_get() | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Not a local patch |
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)
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?
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)
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(-)