mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Markus Elfring <Markus.Elfring@web.de>
Cc: 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>,
	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: Re: [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz()
Date: Thu, 18 Jan 2024 08:29:20 +0300	[thread overview]
Message-ID: <26759e3b-ff74-4b04-b06f-4d68fbc5f606@moroto.mountain> (raw)
In-Reply-To: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de>

On Wed, Jan 17, 2024 at 09:24:12PM +0100, Markus Elfring wrote:
> 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);

This patch is fine as a clean up, but I think it's useful to say that
if you pass a NULL label to persistent_ram_new() then it will return
an error.  It won't crash.  So this patch is a nice cleanup but it's not
a bug fix.

regards,
dan carpenter


  parent reply	other threads:[~2024-01-18  5:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-17 20:24 Markus Elfring
2024-01-18  2:03 ` Kunwu Chan
2024-01-18  5:29 ` Dan Carpenter [this message]
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=26759e3b-ff74-4b04-b06f-4d68fbc5f606@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=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

all inboxes | Powered by JetHome®