DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/1] examples/vm_power_manager: fix resource leak
@ 2020-07-29  8:37 Rory Sexton
  2020-09-18  8:13 ` David Hunt
  2020-10-30 12:30 ` David Marchand
  0 siblings, 2 replies; 3+ messages in thread
From: Rory Sexton @ 2020-07-29  8:37 UTC (permalink / raw)
  To: dev, david.hunt; +Cc: marko.kovacevic

Fix memory leak where variable oob_enable can go out of scope leaking
the storage it points to.

Coverity issue: 337674
Fixes: 95f648ff9ee ("examples/vm_power: make branch ratio threshold per core")

Signed-off-by: Rory Sexton <rory.sexton@intel.com>
---
 examples/vm_power_manager/main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index 77797b1e1..0242cca1a 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -209,6 +209,7 @@ parse_args(int argc, char **argv)
 			}
 			if (branch_ratio <= 0.0 || branch_ratio > 100.0) {
 				printf("invalid branch ratio specified\n");
+				free(oob_enable);
 				return -1;
 			}
 			for (i = 0; i < ci->core_count; i++) {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH 1/1] examples/vm_power_manager: fix resource leak
  2020-07-29  8:37 [dpdk-dev] [PATCH 1/1] examples/vm_power_manager: fix resource leak Rory Sexton
@ 2020-09-18  8:13 ` David Hunt
  2020-10-30 12:30 ` David Marchand
  1 sibling, 0 replies; 3+ messages in thread
From: David Hunt @ 2020-09-18  8:13 UTC (permalink / raw)
  To: Rory Sexton, dev; +Cc: marko.kovacevic

Hi Rory,

On 29/7/2020 9:37 AM, Rory Sexton wrote:
> Fix memory leak where variable oob_enable can go out of scope leaking
> the storage it points to.
>
> Coverity issue: 337674
> Fixes: 95f648ff9ee ("examples/vm_power: make branch ratio threshold per core")
>
> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
> ---
>   examples/vm_power_manager/main.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
> index 77797b1e1..0242cca1a 100644
> --- a/examples/vm_power_manager/main.c
> +++ b/examples/vm_power_manager/main.c
> @@ -209,6 +209,7 @@ parse_args(int argc, char **argv)
>   			}
>   			if (branch_ratio <= 0.0 || branch_ratio > 100.0) {
>   				printf("invalid branch ratio specified\n");
> +				free(oob_enable);
>   				return -1;
>   			}
>   			for (i = 0; i < ci->core_count; i++) {


Acked-by: David Hunt <david.hunt@intel.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH 1/1] examples/vm_power_manager: fix resource leak
  2020-07-29  8:37 [dpdk-dev] [PATCH 1/1] examples/vm_power_manager: fix resource leak Rory Sexton
  2020-09-18  8:13 ` David Hunt
@ 2020-10-30 12:30 ` David Marchand
  1 sibling, 0 replies; 3+ messages in thread
From: David Marchand @ 2020-10-30 12:30 UTC (permalink / raw)
  To: Rory Sexton; +Cc: dev, David Hunt, Kovacevic, Marko

On Wed, Jul 29, 2020 at 10:38 AM Rory Sexton <rory.sexton@intel.com> wrote:
>
> Fix memory leak where variable oob_enable can go out of scope leaking
> the storage it points to.
>
> Coverity issue: 337674
> Fixes: 95f648ff9ee ("examples/vm_power: make branch ratio threshold per core")
>
> Signed-off-by: Rory Sexton <rory.sexton@intel.com>
Acked-by: David Hunt <david.hunt@intel.com>

Applied, thanks Rory.


There is another issue in this code.
Previous branches part of the 'b' option handling will break from the
parsing loop and have the parse_args() function return the option
index where it stopped.
This should instead report a parsing error and have the app fail to initialise.

Something like:
diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index 75d5b5364f..2c394b60fc 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -194,7 +194,7 @@ parse_args(int argc, char **argv)
                                       "core-branch-ratio matrix - [%s]\n",
                                                optarg);
                                free(oob_enable);
-                               break;
+                               return -1;
                        }
                        cnt = parse_branch_ratio(optarg, &branch_ratio);
                        if (cnt < 0) {
@@ -202,7 +202,7 @@ parse_args(int argc, char **argv)
                                       "core-branch-ratio matrix - [%s]\n",
                                                optarg);
                                free(oob_enable);
-                               break;
+                               return -1;
                        }
                        if (branch_ratio <= 0.0 || branch_ratio > 100.0) {
                                printf("invalid branch ratio specified\n");

Could you test this and send a followup patch?
Thanks.


-- 
David Marchand


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-10-30 12:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29  8:37 [dpdk-dev] [PATCH 1/1] examples/vm_power_manager: fix resource leak Rory Sexton
2020-09-18  8:13 ` David Hunt
2020-10-30 12:30 ` 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).