mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kunwu Chan <chentao@kylinos.cn>
To: Markus Elfring <Markus.Elfring@web.de>,
	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>
Subject: Re: [PATCH] pstore/ram: Return directly after a failed kasprintf() call in ramoops_init_prz()
Date: Thu, 18 Jan 2024 10:03:37 +0800	[thread overview]
Message-ID: <e583bcd5-cae6-4299-8800-80e862a6bd8f@kylinos.cn> (raw)
In-Reply-To: <644f44ad-7e2b-4a1a-bbd7-ccc79d479242@web.de>

Hi Markus,
Thanks for your patch.

On 2024/1/18 04:24, 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;
> +

This part looks good to me.

Commit 1227daa43bce1 ("pstore/ram: Clarify resource reservation labels")
introduce another two more kasprintf in the ramoops_init_przs.

Could you fix it together?
>   	*prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info,
>   				  cxt->memtype, PRZ_FLAG_ZAP_OLD, label);
>   	kfree(label);
> --
> 2.43.0
> 
-- 
Thanks,
   Kunwu


  reply	other threads:[~2024-01-18  2:09 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 [this message]
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=e583bcd5-cae6-4299-8800-80e862a6bd8f@kylinos.cn \
    --to=chentao@kylinos.cn \
    --cc=Markus.Elfring@web.de \
    --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®