public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-edac@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Borislav Petkov <bp@alien8.de>, James Morse <james.morse@arm.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Robert Richter <rric@kernel.org>, Tony Luck <tony.luck@intel.com>,
	Yazen Ghannam <yazen.ghannam@amd.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	cocci@inria.fr, Muralidhara M K <muralidhara.mk@amd.com>
Subject: [PATCH 4/7] EDAC/amd64: Adjust error handling in probe_one_instance()
Date: Mon, 25 Dec 2023 18:40:26 +0100	[thread overview]
Message-ID: <0dcdeebf-46f1-41c1-b5c8-050bca5d8e1f@web.de> (raw)
In-Reply-To: <8c9e2c01-9ed0-4392-af40-4e8eb393cb67@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 25 Dec 2023 17:18:14 +0100

1. Return directly after a call of the function “kzalloc” failed
   at the beginning.

2. Delete the label “err_out” which became unnecessary
   with this refactoring.

3. Move an error code assignment into an if branch.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/edac/amd64_edac.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 49f3d9b54902..64680de47cab 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -4268,16 +4268,17 @@ static int probe_one_instance(unsigned int nid)
 	struct ecc_settings *s;
 	int ret;

-	ret = -ENOMEM;
 	s = kzalloc(sizeof(struct ecc_settings), GFP_KERNEL);
 	if (!s)
-		goto err_out;
+		return -ENOMEM;

 	ecc_stngs[nid] = s;

 	pvt = kzalloc(sizeof(struct amd64_pvt), GFP_KERNEL);
-	if (!pvt)
+	if (!pvt) {
+		ret = -ENOMEM;
 		goto err_settings;
+	}

 	pvt->mc_node_id	= nid;
 	pvt->F3 = F3;
@@ -4336,8 +4337,6 @@ static int probe_one_instance(unsigned int nid)
 err_settings:
 	kfree(s);
 	ecc_stngs[nid] = NULL;
-
-err_out:
 	return ret;
 }

--
2.43.0


  parent reply	other threads:[~2023-12-25 17:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-25 17:32 [PATCH 0/7] EDAC/amd64: Adjustments for two function implementations Markus Elfring
2023-12-25 17:34 ` [PATCH 1/7] EDAC/amd64: Improve error handling in amd64_edac_init() Markus Elfring
2023-12-25 17:36 ` [PATCH 2/7] EDAC/amd64: Delete an unnecessary variable initialisation " Markus Elfring
2023-12-25 17:38 ` [PATCH 3/7] EDAC/amd64: Merge two if statements into one " Markus Elfring
2023-12-25 17:40 ` Markus Elfring [this message]
2023-12-25 17:42 ` [PATCH 5/7] EDAC/amd64: Improve two size determinations in probe_one_instance() Markus Elfring
2023-12-25 17:44 ` [PATCH 6/7] EDAC/amd64: Delete an unnecessary variable initialisation " Markus Elfring
2023-12-25 17:46 ` [PATCH 7/7] EDAC/amd64: Move an assignment for the variable “F3” " Markus Elfring

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=0dcdeebf-46f1-41c1-b5c8-050bca5d8e1f@web.de \
    --to=markus.elfring@web.de \
    --cc=bp@alien8.de \
    --cc=cocci@inria.fr \
    --cc=james.morse@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=muralidhara.mk@amd.com \
    --cc=rric@kernel.org \
    --cc=tony.luck@intel.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