From: Markus Elfring <Markus.Elfring@web.de>
To: linux-hardening@vger.kernel.org, kernel-janitors@vger.kernel.org,
"Guilherme G. Piccoli" <gpiccoli@igalia.com>,
Joel Fernandes <joel@joelfernandes.org>,
Kees Cook <keescook@chromium.org>,
Tony Luck <tony.luck@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Günter Röck" <groeck@chromium.org>,
"Sai Prakash Ranjan" <saiprakash.ranjan@codeaurora.org>,
"Kunwu Chan" <chentao@kylinos.cn>
Subject: [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz()
Date: Wed, 17 Jan 2024 21:24:12 +0100 [thread overview]
Message-ID: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 17 Jan 2024 21:09:22 +0100
The result from a call of the function “kasprintf” was passed to
a subsequent function call without checking for a null pointer before
(according to a memory allocation failure).
This issue was detected by using the Coccinelle software.
Thus return directly after a failed kasprintf() call.
Fixes: 1227daa43bce1 ("pstore/ram: Clarify resource reservation labels")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
fs/pstore/ram.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 88b34fdbf759..1a673a4af17c 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -595,6 +595,9 @@ static int ramoops_init_prz(const char *name,
}
label = kasprintf(GFP_KERNEL, "ramoops:%s", name);
+ if (!label)
+ return -ENOMEM;
+
*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
cxt->memtype, PRZ_FLAG_ZAP_OLD, label);
kfree(label);
--
2.43.0
next reply other threads:[~2024-01-17 20:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-17 20:24 Markus Elfring [this message]
2024-01-18 2:03 ` [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz() Kunwu Chan
2024-01-18 5:29 ` Dan Carpenter
2024-01-18 8:38 ` 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=644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de \
--to=markus.elfring@web.de \
--cc=chentao@kylinos.cn \
--cc=gpiccoli@igalia.com \
--cc=groeck@chromium.org \
--cc=joel@joelfernandes.org \
--cc=keescook@chromium.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=saiprakash.ranjan@codeaurora.org \
--cc=tony.luck@intel.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