* [dpdk-dev] [PATCH] power: fix coverity issue
@ 2019-04-08 15:21 Liang Ma
2019-04-08 15:21 ` Liang Ma
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Liang Ma @ 2019-04-08 15:21 UTC (permalink / raw)
To: dev; +Cc: david.hunt, anatoly.burakov, Liang Ma
Coverity issue: 337668
Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
Signed-off-by: Liang Ma <liang.j.ma@intel.com>
---
lib/librte_power/power_pstate_cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 336c13869..db2f7a0f4 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -197,6 +197,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
/ BUS_FREQ;
}
+ if (f_base != NULL)
+ fclose(f_base);
+
/* Add MSR read to detect turbo status */
if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH] power: fix coverity issue
2019-04-08 15:21 [dpdk-dev] [PATCH] power: fix coverity issue Liang Ma
@ 2019-04-08 15:21 ` Liang Ma
2019-04-08 15:32 ` Hunt, David
2019-04-08 16:19 ` [dpdk-dev] [PATCH v2] " Liang Ma
2 siblings, 0 replies; 10+ messages in thread
From: Liang Ma @ 2019-04-08 15:21 UTC (permalink / raw)
To: dev; +Cc: david.hunt, anatoly.burakov, Liang Ma
Coverity issue: 337668
Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
Signed-off-by: Liang Ma <liang.j.ma@intel.com>
---
lib/librte_power/power_pstate_cpufreq.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 336c13869..db2f7a0f4 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -197,6 +197,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
/ BUS_FREQ;
}
+ if (f_base != NULL)
+ fclose(f_base);
+
/* Add MSR read to detect turbo status */
if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH] power: fix coverity issue
2019-04-08 15:21 [dpdk-dev] [PATCH] power: fix coverity issue Liang Ma
2019-04-08 15:21 ` Liang Ma
@ 2019-04-08 15:32 ` Hunt, David
2019-04-08 15:32 ` Hunt, David
2019-04-08 16:19 ` [dpdk-dev] [PATCH v2] " Liang Ma
2 siblings, 1 reply; 10+ messages in thread
From: Hunt, David @ 2019-04-08 15:32 UTC (permalink / raw)
To: Liang Ma, dev; +Cc: anatoly.burakov
Hi Liang,
On 8/4/2019 4:21 PM, Liang Ma wrote:
> Coverity issue: 337668
>
> Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
>
> Signed-off-by: Liang Ma <liang.j.ma@intel.com>
> ---
> lib/librte_power/power_pstate_cpufreq.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
> index 336c13869..db2f7a0f4 100644
> --- a/lib/librte_power/power_pstate_cpufreq.c
> +++ b/lib/librte_power/power_pstate_cpufreq.c
> @@ -197,6 +197,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
> / BUS_FREQ;
> }
>
> + if (f_base != NULL)
> + fclose(f_base);
> +
> /* Add MSR read to detect turbo status */
>
> if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
Rather than adding a new 'if' statement, you could just add the fclose()
to the previous section, which checks for a similar condition. Maybe
just after the FOPS_OR_NULL_GOTO() (line 189).
Rgds,
Dave.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH] power: fix coverity issue
2019-04-08 15:32 ` Hunt, David
@ 2019-04-08 15:32 ` Hunt, David
0 siblings, 0 replies; 10+ messages in thread
From: Hunt, David @ 2019-04-08 15:32 UTC (permalink / raw)
To: Liang Ma, dev; +Cc: anatoly.burakov
Hi Liang,
On 8/4/2019 4:21 PM, Liang Ma wrote:
> Coverity issue: 337668
>
> Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
>
> Signed-off-by: Liang Ma <liang.j.ma@intel.com>
> ---
> lib/librte_power/power_pstate_cpufreq.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
> index 336c13869..db2f7a0f4 100644
> --- a/lib/librte_power/power_pstate_cpufreq.c
> +++ b/lib/librte_power/power_pstate_cpufreq.c
> @@ -197,6 +197,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
> / BUS_FREQ;
> }
>
> + if (f_base != NULL)
> + fclose(f_base);
> +
> /* Add MSR read to detect turbo status */
>
> if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
Rather than adding a new 'if' statement, you could just add the fclose()
to the previous section, which checks for a similar condition. Maybe
just after the FOPS_OR_NULL_GOTO() (line 189).
Rgds,
Dave.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2] power: fix coverity issue
2019-04-08 15:21 [dpdk-dev] [PATCH] power: fix coverity issue Liang Ma
2019-04-08 15:21 ` Liang Ma
2019-04-08 15:32 ` Hunt, David
@ 2019-04-08 16:19 ` Liang Ma
2019-04-08 16:19 ` Liang Ma
2019-05-03 9:26 ` Hunt, David
2 siblings, 2 replies; 10+ messages in thread
From: Liang Ma @ 2019-04-08 16:19 UTC (permalink / raw)
To: dev; +Cc: david.hunt, anatoly.burakov, Liang Ma
Fix the resource leaking issue
Coverity issue: 337668
Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
Signed-off-by: Liang Ma <liang.j.ma@intel.com>
---
lib/librte_power/power_pstate_cpufreq.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 336c13869..07ca5c1dd 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -158,6 +158,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
char *s_base;
uint32_t base_ratio = 0;
uint64_t max_non_turbo = 0;
+ int ret_val = 0;
snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
pi->lcore_id);
@@ -199,8 +200,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
/* Add MSR read to detect turbo status */
- if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
- return -1;
+ if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) {
+ ret_val = -1;
+ goto out;
+ }
max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET;
@@ -219,7 +222,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
pi->core_base_freq = base_ratio * BUS_FREQ;
out:
- return 0;
+ if (f_base != NULL)
+ fclose(f_base);
+ return ret_val;
}
static int
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH v2] power: fix coverity issue
2019-04-08 16:19 ` [dpdk-dev] [PATCH v2] " Liang Ma
@ 2019-04-08 16:19 ` Liang Ma
2019-05-03 9:26 ` Hunt, David
1 sibling, 0 replies; 10+ messages in thread
From: Liang Ma @ 2019-04-08 16:19 UTC (permalink / raw)
To: dev; +Cc: david.hunt, anatoly.burakov, Liang Ma
Fix the resource leaking issue
Coverity issue: 337668
Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
Signed-off-by: Liang Ma <liang.j.ma@intel.com>
---
lib/librte_power/power_pstate_cpufreq.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
index 336c13869..07ca5c1dd 100644
--- a/lib/librte_power/power_pstate_cpufreq.c
+++ b/lib/librte_power/power_pstate_cpufreq.c
@@ -158,6 +158,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
char *s_base;
uint32_t base_ratio = 0;
uint64_t max_non_turbo = 0;
+ int ret_val = 0;
snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
pi->lcore_id);
@@ -199,8 +200,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
/* Add MSR read to detect turbo status */
- if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
- return -1;
+ if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) {
+ ret_val = -1;
+ goto out;
+ }
max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET;
@@ -219,7 +222,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
pi->core_base_freq = base_ratio * BUS_FREQ;
out:
- return 0;
+ if (f_base != NULL)
+ fclose(f_base);
+ return ret_val;
}
static int
--
2.17.2
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] power: fix coverity issue
2019-04-08 16:19 ` [dpdk-dev] [PATCH v2] " Liang Ma
2019-04-08 16:19 ` Liang Ma
@ 2019-05-03 9:26 ` Hunt, David
2019-05-03 9:26 ` Hunt, David
2019-05-09 18:46 ` Thomas Monjalon
1 sibling, 2 replies; 10+ messages in thread
From: Hunt, David @ 2019-05-03 9:26 UTC (permalink / raw)
To: Liang Ma, dev; +Cc: anatoly.burakov
On 8/4/2019 5:19 PM, Liang Ma wrote:
> Fix the resource leaking issue
>
> Coverity issue: 337668
>
> Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
>
> Signed-off-by: Liang Ma <liang.j.ma@intel.com>
> ---
> lib/librte_power/power_pstate_cpufreq.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
> index 336c13869..07ca5c1dd 100644
> --- a/lib/librte_power/power_pstate_cpufreq.c
> +++ b/lib/librte_power/power_pstate_cpufreq.c
> @@ -158,6 +158,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
> char *s_base;
> uint32_t base_ratio = 0;
> uint64_t max_non_turbo = 0;
> + int ret_val = 0;
>
> snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
> pi->lcore_id);
> @@ -199,8 +200,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
>
> /* Add MSR read to detect turbo status */
>
> - if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
> - return -1;
> + if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) {
> + ret_val = -1;
> + goto out;
> + }
>
> max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET;
>
> @@ -219,7 +222,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
> pi->core_base_freq = base_ratio * BUS_FREQ;
>
> out:
> - return 0;
> + if (f_base != NULL)
> + fclose(f_base);
> + return ret_val;
> }
>
> static int
Confirmed that this issue is resolved by testing on our internel
Coverity server here, version 8.7.1
Tested-by: David Hunt <david.hunt@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] power: fix coverity issue
2019-05-03 9:26 ` Hunt, David
@ 2019-05-03 9:26 ` Hunt, David
2019-05-09 18:46 ` Thomas Monjalon
1 sibling, 0 replies; 10+ messages in thread
From: Hunt, David @ 2019-05-03 9:26 UTC (permalink / raw)
To: Liang Ma, dev; +Cc: anatoly.burakov
On 8/4/2019 5:19 PM, Liang Ma wrote:
> Fix the resource leaking issue
>
> Coverity issue: 337668
>
> Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
>
> Signed-off-by: Liang Ma <liang.j.ma@intel.com>
> ---
> lib/librte_power/power_pstate_cpufreq.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c
> index 336c13869..07ca5c1dd 100644
> --- a/lib/librte_power/power_pstate_cpufreq.c
> +++ b/lib/librte_power/power_pstate_cpufreq.c
> @@ -158,6 +158,7 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
> char *s_base;
> uint32_t base_ratio = 0;
> uint64_t max_non_turbo = 0;
> + int ret_val = 0;
>
> snprintf(fullpath_min, sizeof(fullpath_min), POWER_SYSFILE_MIN_FREQ,
> pi->lcore_id);
> @@ -199,8 +200,10 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
>
> /* Add MSR read to detect turbo status */
>
> - if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0)
> - return -1;
> + if (power_rdmsr(PLATFORM_INFO, &max_non_turbo, pi->lcore_id) < 0) {
> + ret_val = -1;
> + goto out;
> + }
>
> max_non_turbo = (max_non_turbo&NON_TURBO_MASK)>>NON_TURBO_OFFSET;
>
> @@ -219,7 +222,9 @@ power_init_for_setting_freq(struct pstate_power_info *pi)
> pi->core_base_freq = base_ratio * BUS_FREQ;
>
> out:
> - return 0;
> + if (f_base != NULL)
> + fclose(f_base);
> + return ret_val;
> }
>
> static int
Confirmed that this issue is resolved by testing on our internel
Coverity server here, version 8.7.1
Tested-by: David Hunt <david.hunt@intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] power: fix coverity issue
2019-05-03 9:26 ` Hunt, David
2019-05-03 9:26 ` Hunt, David
@ 2019-05-09 18:46 ` Thomas Monjalon
2019-05-09 18:46 ` Thomas Monjalon
1 sibling, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2019-05-09 18:46 UTC (permalink / raw)
To: Liang Ma; +Cc: dev, Hunt, David, anatoly.burakov
03/05/2019 11:26, Hunt, David:
> On 8/4/2019 5:19 PM, Liang Ma wrote:
> > Fix the resource leaking issue
> >
> > Coverity issue: 337668
> >
> > Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
>
> Confirmed that this issue is resolved by testing on our internel
> Coverity server here, version 8.7.1
>
> Tested-by: David Hunt <david.hunt@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH v2] power: fix coverity issue
2019-05-09 18:46 ` Thomas Monjalon
@ 2019-05-09 18:46 ` Thomas Monjalon
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Monjalon @ 2019-05-09 18:46 UTC (permalink / raw)
To: Liang Ma; +Cc: dev, Hunt, David, anatoly.burakov
03/05/2019 11:26, Hunt, David:
> On 8/4/2019 5:19 PM, Liang Ma wrote:
> > Fix the resource leaking issue
> >
> > Coverity issue: 337668
> >
> > Fixes: b60fd5f8b1ce8f0a2c ("power: add bit for high frequency cores")
>
> Confirmed that this issue is resolved by testing on our internel
> Coverity server here, version 8.7.1
>
> Tested-by: David Hunt <david.hunt@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-05-09 18:46 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-08 15:21 [dpdk-dev] [PATCH] power: fix coverity issue Liang Ma
2019-04-08 15:21 ` Liang Ma
2019-04-08 15:32 ` Hunt, David
2019-04-08 15:32 ` Hunt, David
2019-04-08 16:19 ` [dpdk-dev] [PATCH v2] " Liang Ma
2019-04-08 16:19 ` Liang Ma
2019-05-03 9:26 ` Hunt, David
2019-05-03 9:26 ` Hunt, David
2019-05-09 18:46 ` Thomas Monjalon
2019-05-09 18:46 ` Thomas Monjalon
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).