devargs: fix leak on hotplug failure

Message ID 20220414112756.26119-1-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series devargs: fix leak on hotplug failure |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

David Marchand April 14, 2022, 11:27 a.m. UTC
  Caught by ASan, if a secondary process tried to attach a device with an
incorrect driver name, devargs was leaked.

Fixes: 64051bb1f144 ("devargs: unify scratch buffer storage")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 lib/eal/common/eal_common_dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

David Marchand May 12, 2022, 7:06 a.m. UTC | #1
On Thu, Apr 14, 2022 at 1:28 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> Caught by ASan, if a secondary process tried to attach a device with an
> incorrect driver name, devargs was leaked.
>
> Fixes: 64051bb1f144 ("devargs: unify scratch buffer storage")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Review please?
  
David Marchand May 19, 2022, 4:21 p.m. UTC | #2
On Thu, May 12, 2022 at 9:06 AM David Marchand
<david.marchand@redhat.com> wrote:
> On Thu, Apr 14, 2022 at 1:28 PM David Marchand
> <david.marchand@redhat.com> wrote:
> >
> > Caught by ASan, if a secondary process tried to attach a device with an
> > incorrect driver name, devargs was leaked.
> >
> > Fixes: 64051bb1f144 ("devargs: unify scratch buffer storage")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
>
> Review please?

No objection, the fix has been around for one month.
Applied.
  

Patch

diff --git a/lib/eal/common/eal_common_dev.c b/lib/eal/common/eal_common_dev.c
index c0ee4e442f..9d913e5478 100644
--- a/lib/eal/common/eal_common_dev.c
+++ b/lib/eal/common/eal_common_dev.c
@@ -180,8 +180,10 @@  local_dev_probe(const char *devargs, struct rte_device **new_dev)
 	return ret;
 
 err_devarg:
-	if (rte_devargs_remove(da) != 0)
+	if (rte_devargs_remove(da) != 0) {
 		rte_devargs_reset(da);
+		free(da);
+	}
 	return ret;
 }