mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ren Yu <renyu@nfschina.com>
To: keescook@chromium.org, arnd@arndb.de, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org
Cc: liqiong@nfschina.com, yuzhe@nfschina.com, Ren Yu <renyu@nfschina.com>
Subject: [PATCH 1/3] lkdtm/fortify: Check possible NULL pointer returned by kmalloc()
Date: Mon, 25 Jul 2022 16:10:00 +0800	[thread overview]
Message-ID: <20220725081000.19407-1-renyu@nfschina.com> (raw)

As the possible alloc failure of the kmalloc(),the return pointer
could be NULL,therefore it should be better to check it.

Signed-off-by: Ren Yu <renyu@nfschina.com>
---
 drivers/misc/lkdtm/fortify.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/misc/lkdtm/fortify.c b/drivers/misc/lkdtm/fortify.c
index 080293fa3c52..5d70c5ef918b 100644
--- a/drivers/misc/lkdtm/fortify.c
+++ b/drivers/misc/lkdtm/fortify.c
@@ -41,6 +41,9 @@ static void lkdtm_FORTIFIED_SUBOBJECT(void)
 	char *src;
 
 	src = kmalloc(size, GFP_KERNEL);
+	if (!src)
+		return;
+
 	strscpy(src, "over ten bytes", size);
 	size = strlen(src) + 1;
 
-- 
2.11.0


             reply	other threads:[~2022-07-25  8:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-25  8:10 Ren Yu [this message]
2022-07-25  8:41 ` Greg KH

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=20220725081000.19407-1-renyu@nfschina.com \
    --to=renyu@nfschina.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liqiong@nfschina.com \
    --cc=yuzhe@nfschina.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®