linux-edac.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Yazen Ghannam <yazen.ghannam@amd.com>,
	Borislav Petkov <bp@alien8.de>, Tony Luck <tony.luck@intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>, James Morse <james.morse@arm.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Robert Richter <rric@kernel.org>,
	William Roche <william.roche@oracle.com>,
	Muralidhara M K <muralimk@amd.com>, Jia He <justin.he@arm.com>,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] EDAC/amd64: avoid uninitialized variable use
Date: Tue, 14 Feb 2023 11:33:14 +0100	[thread overview]
Message-ID: <20230214103318.1294909-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

hw_info_get() tries to reserve two sibling devices, but the device IDs are
no longer initialized for Fam17 CPUs:

drivers/edac/amd64_edac.c:3936:7: error: variable 'pci_id1' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                if (!pvt->umc)
                    ^~~~~~~~~
drivers/edac/amd64_edac.c:3943:37: note: uninitialized use occurs here
        ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
                                           ^~~~~~~
drivers/edac/amd64_edac.c:3936:3: note: remove the 'if' if its condition is always true
                if (!pvt->umc)
                ^~~~~~~~~~~~~~
drivers/edac/amd64_edac.c:3936:7: error: variable 'pci_id2' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
                if (!pvt->umc)
                    ^~~~~~~~~
drivers/edac/amd64_edac.c:3943:46: note: uninitialized use occurs here
        ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
                                                    ^~~~~~~
drivers/edac/amd64_edac.c:3936:3: note: remove the 'if' if its condition is always true
                if (!pvt->umc)
                ^~~~~~~~~~~~~~

Move this code into the 'else' branch where it is still possible.

Fixes: 6229235f7c66 ("EDAC/amd64: Remove PCI Function 6")
Fixes: cf981562e627 ("EDAC/amd64: Remove PCI Function 0")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
I have no idea if this change makes sense, this is merely a guess
based on the description of the two other commits.
---
 drivers/edac/amd64_edac.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 1c4bef1cdf28..a149cd95e806 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -3938,11 +3938,11 @@ static int hw_info_get(struct amd64_pvt *pvt)
 	} else {
 		pci_id1 = fam_type->f1_id;
 		pci_id2 = fam_type->f2_id;
-	}
 
-	ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
-	if (ret)
-		return ret;
+		ret = reserve_mc_sibling_devs(pvt, pci_id1, pci_id2);
+		if (ret)
+			return ret;
+	}
 
 	read_mc_regs(pvt);
 
-- 
2.39.1


                 reply	other threads:[~2023-02-14 10:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230214103318.1294909-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=justin.he@arm.com \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=muralimk@amd.com \
    --cc=rric@kernel.org \
    --cc=tony.luck@intel.com \
    --cc=william.roche@oracle.com \
    --cc=yazen.ghannam@amd.com \
    /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 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).