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: [PATCH 1/2] nfc: mei_phy: Return directly after a failed kzalloc() in mei_nfc_send()
Date: Wed, 27 Dec 2023 17:02:03 +0100 [thread overview]
Message-ID: <0a98d3b6-e0ec-408a-aa2d-f2b23dcff26f@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:30:20 +0100
The kfree() function was called in one case by
the mei_nfc_send() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.
Thus return directly after a call of the function “kzalloc” failed
at the beginning.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/nfc/mei_phy.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
index f9cca885beec..937f229f4646 100644
--- a/drivers/nfc/mei_phy.c
+++ b/drivers/nfc/mei_phy.c
@@ -208,10 +208,9 @@ static int mei_nfc_send(struct nfc_mei_phy *phy, const u8 *buf, size_t length)
u8 *mei_buf;
int err;
- err = -ENOMEM;
mei_buf = kzalloc(length + MEI_NFC_HEADER_SIZE, GFP_KERNEL);
if (!mei_buf)
- goto out;
+ return -ENOMEM;
hdr = (struct mei_nfc_hdr *)mei_buf;
hdr->cmd = MEI_NFC_CMD_HCI_SEND;
--
2.43.0
next prev parent reply other threads:[~2023-12-27 16:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-27 16:00 [PATCH 0/2] nfc: mei_phy: Adjustments for two function implementations Markus Elfring
2023-12-27 16:02 ` Markus Elfring [this message]
2023-12-27 16:04 ` [PATCH 2/2] nfc: mei_phy: Use common code in mei_nfc_connect() 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=0a98d3b6-e0ec-408a-aa2d-f2b23dcff26f@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
all inboxes | Powered by JetHome®