All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org, David Hunt <david.hunt@intel.com>
Cc: anatoly.burakov@intel.com
Subject: [dpdk-dev] [PATCH v1 1/1] power: fix potential null dereferences
Date: Fri,  9 Jul 2021 15:01:16 +0000	[thread overview]
Message-ID: <77dc13d24d7c77526e088756784ce073bc02fe7f.1625842874.git.anatoly.burakov@intel.com> (raw)

Currently, the error paths can lead to attempts at dereferencing NULL
pointers. Add the check to avoid attempts at dereferencing NULL
pointers.

Fixes: 06cffd468fdd ("power: refactor ACPI and intel_pstate support")
Cc: anatoly.burakov@intel.com

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/power/power_pstate_cpufreq.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index ba28ddcfca..3b607515fd 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -440,8 +440,10 @@ power_get_available_freqs(struct pstate_power_info *pi)
 			num_freqs, pi->lcore_id);
 
 out:
-	fclose(f_min);
-	fclose(f_max);
+	if (f_min != NULL)
+		fclose(f_min);
+	if (f_max != NULL)
+		fclose(f_max);
 
 	return ret;
 }
-- 
2.25.1


             reply	other threads:[~2021-07-09 15:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 15:01 Anatoly Burakov [this message]
2021-07-09 15:09 ` [dpdk-dev] [PATCH v1 1/1] power: fix potential null dereferences David Marchand
2021-07-09 15:19   ` David Hunt
2021-07-09 15:55 ` [dpdk-dev] [PATCH v2 " Anatoly Burakov
2021-07-20 15:21   ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77dc13d24d7c77526e088756784ce073bc02fe7f.1625842874.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.