Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>, cocci@inria.fr
Subject: [cocci] [PATCH 2/2] nfc: mei_phy: Use common code in mei_nfc_connect()
Date: Wed, 27 Dec 2023 17:04:07 +0100	[thread overview]
Message-ID: <fcc9f3ed-b8d0-4999-a06c-12a193a516d3@web.de> (raw)
In-Reply-To: <9a683f73-c5a2-4b80-af1b-01540834a3dd@web.de>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 27 Dec 2023 16:45:39 +0100

Use another label so that a kfree() call can be better reused
at the end of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/nfc/mei_phy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
index 937f229f4646..9272564012b3 100644
--- a/drivers/nfc/mei_phy.c
+++ b/drivers/nfc/mei_phy.c
@@ -157,8 +157,8 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)

 	reply = kzalloc(connect_resp_length, GFP_KERNEL);
 	if (!reply) {
-		kfree(cmd);
-		return -ENOMEM;
+		r = -ENOMEM;
+		goto free_cmd;
 	}

 	connect_resp = (struct mei_nfc_connect_resp *)reply->data;
@@ -197,6 +197,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)

 err:
 	kfree(reply);
+free_cmd:
 	kfree(cmd);

 	return r;
--
2.43.0


      parent reply	other threads:[~2023-12-27 16:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-27 16:00 [cocci] [PATCH 0/2] nfc: mei_phy: Adjustments for two function implementations Markus Elfring
2023-12-27 16:02 ` [cocci] [PATCH 1/2] nfc: mei_phy: Return directly after a failed kzalloc() in mei_nfc_send() Markus Elfring
2023-12-27 16:04 ` Markus Elfring [this message]

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=fcc9f3ed-b8d0-4999-a06c-12a193a516d3@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).