* [dpdk-dev] [PATCH] metrics: fix resource leak on memory allocation fail
@ 2020-09-17 15:03 Ciara Power
2020-09-17 16:08 ` [dpdk-dev] [dpdk-stable] " Mcnamara, John
2020-11-03 21:36 ` [dpdk-dev] " David Marchand
0 siblings, 2 replies; 5+ messages in thread
From: Ciara Power @ 2020-09-17 15:03 UTC (permalink / raw)
To: dev; +Cc: Ciara Power, stable, Keith Wiles
If an error occurred when allocating memory for metrics or names,
the function returned without freeing allocated memory. This is now
fixed to avoid the resource leak in the case that either metrics or
names had been successfully allocated memory.
Coverity issue: 362053
Fixes: c5b7197f662e ("telemetry: move some functions to metrics library")
Cc: stable@dpdk.org
Signed-off-by: Ciara Power <ciara.power@intel.com>
---
lib/librte_metrics/rte_metrics_telemetry.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/librte_metrics/rte_metrics_telemetry.c b/lib/librte_metrics/rte_metrics_telemetry.c
index 289ebae0bd..36a3821b4c 100644
--- a/lib/librte_metrics/rte_metrics_telemetry.c
+++ b/lib/librte_metrics/rte_metrics_telemetry.c
@@ -170,7 +170,8 @@ rte_metrics_tel_format_port(uint32_t pid, json_t *ports,
names = malloc(sizeof(struct rte_metric_name) * num_metrics);
if (metrics == NULL || names == NULL) {
METRICS_LOG_ERR("Cannot allocate memory");
- return -ENOMEM;
+ ret = -ENOMEM;
+ goto fail;
}
if (rte_metrics_get_names(names, num_metrics) != num_metrics ||
--
2.17.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] metrics: fix resource leak on memory allocation fail
2020-09-17 15:03 [dpdk-dev] [PATCH] metrics: fix resource leak on memory allocation fail Ciara Power
@ 2020-09-17 16:08 ` Mcnamara, John
2020-09-21 23:43 ` Honnappa Nagarahalli
2020-11-03 21:36 ` [dpdk-dev] " David Marchand
1 sibling, 1 reply; 5+ messages in thread
From: Mcnamara, John @ 2020-09-17 16:08 UTC (permalink / raw)
To: Power, Ciara, dev; +Cc: Power, Ciara, stable, Wiles, Keith
> If an error occurred when allocating memory for metrics or names, the
> function returned without freeing allocated memory. This is now fixed to
> avoid the resource leak in the case that either metrics or names had been
> successfully allocated memory.
>
> Coverity issue: 362053
> Fixes: c5b7197f662e ("telemetry: move some functions to metrics library")
> Cc: stable@dpdk.org
Acked-by: John McNamara <john.mcnamara@intel.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] metrics: fix resource leak on memory allocation fail
2020-09-17 16:08 ` [dpdk-dev] [dpdk-stable] " Mcnamara, John
@ 2020-09-21 23:43 ` Honnappa Nagarahalli
2020-09-22 10:28 ` Power, Ciara
0 siblings, 1 reply; 5+ messages in thread
From: Honnappa Nagarahalli @ 2020-09-21 23:43 UTC (permalink / raw)
To: Mcnamara, John, Power, Ciara, dev
Cc: Power, Ciara, stable, Wiles, Keith, nd, Honnappa Nagarahalli, nd
<snip>
>
> > If an error occurred when allocating memory for metrics or names, the
> > function returned without freeing allocated memory. This is now fixed
> > to avoid the resource leak in the case that either metrics or names
> > had been successfully allocated memory.
> >
> > Coverity issue: 362053
> > Fixes: c5b7197f662e ("telemetry: move some functions to metrics
> > library")
> > Cc: stable@dpdk.org
>
> Acked-by: John McNamara <john.mcnamara@intel.com>
>
This is fixed in https://patches.dpdk.org/patch/75323/. Can you please check if that suffices?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [dpdk-stable] [PATCH] metrics: fix resource leak on memory allocation fail
2020-09-21 23:43 ` Honnappa Nagarahalli
@ 2020-09-22 10:28 ` Power, Ciara
0 siblings, 0 replies; 5+ messages in thread
From: Power, Ciara @ 2020-09-22 10:28 UTC (permalink / raw)
To: Honnappa Nagarahalli, Mcnamara, John, dev; +Cc: stable, Wiles, Keith, nd, nd
Hi Honnappa,
>-----Original Message-----
>From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
>Sent: Tuesday 22 September 2020 00:43
>To: Mcnamara, John <john.mcnamara@intel.com>; Power, Ciara
><ciara.power@intel.com>; dev@dpdk.org
>Cc: Power, Ciara <ciara.power@intel.com>; stable@dpdk.org; Wiles, Keith
><keith.wiles@intel.com>; nd <nd@arm.com>; Honnappa Nagarahalli
><Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
>Subject: RE: [dpdk-dev] [dpdk-stable] [PATCH] metrics: fix resource leak on
>memory allocation fail
>
><snip>
>
>>
>> > If an error occurred when allocating memory for metrics or names,
>> > the function returned without freeing allocated memory. This is now
>> > fixed to avoid the resource leak in the case that either metrics or
>> > names had been successfully allocated memory.
>> >
>> > Coverity issue: 362053
>> > Fixes: c5b7197f662e ("telemetry: move some functions to metrics
>> > library")
>> > Cc: stable@dpdk.org
>>
>> Acked-by: John McNamara <john.mcnamara@intel.com>
>>
>This is fixed in https://patches.dpdk.org/patch/75323/. Can you please check
>if that suffices?
I left some comments on that patch, but seeing as it is fixing the same issue, I will remove this patch.
Thanks,
Ciara
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH] metrics: fix resource leak on memory allocation fail
2020-09-17 15:03 [dpdk-dev] [PATCH] metrics: fix resource leak on memory allocation fail Ciara Power
2020-09-17 16:08 ` [dpdk-dev] [dpdk-stable] " Mcnamara, John
@ 2020-11-03 21:36 ` David Marchand
1 sibling, 0 replies; 5+ messages in thread
From: David Marchand @ 2020-11-03 21:36 UTC (permalink / raw)
To: Ciara Power
Cc: dev, dpdk stable, Keith Wiles, Gaurav Singh, Honnappa Nagarahalli
On Thu, Sep 17, 2020 at 5:06 PM Ciara Power <ciara.power@intel.com> wrote:
>
> If an error occurred when allocating memory for metrics or names,
> the function returned without freeing allocated memory. This is now
> fixed to avoid the resource leak in the case that either metrics or
> names had been successfully allocated memory.
>
> Coverity issue: 362053
> Fixes: c5b7197f662e ("telemetry: move some functions to metrics library")
> Cc: stable@dpdk.org
>
Gaurav reported the same issue and proposed a patch, but I went with
yours as it describes the issue, is minimal and has the proper tags
for backport.
Reported-by: Gaurav Singh <gaurav1086@gmail.com>
> Signed-off-by: Ciara Power <ciara.power@intel.com>
Acked-by: John McNamara <john.mcnamara@intel.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-11-03 21:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 15:03 [dpdk-dev] [PATCH] metrics: fix resource leak on memory allocation fail Ciara Power
2020-09-17 16:08 ` [dpdk-dev] [dpdk-stable] " Mcnamara, John
2020-09-21 23:43 ` Honnappa Nagarahalli
2020-09-22 10:28 ` Power, Ciara
2020-11-03 21:36 ` [dpdk-dev] " David Marchand
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).