All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH] init/initramfs.c: check the return value of kstrdup()
Date: Tue, 14 Dec 2021 04:51:18 +0800	[thread overview]
Message-ID: <202112140423.37WdeaEE-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 2972 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <tencent_B8A4989923779B6381A23A5C4209FD7F1E05@qq.com>
References: <tencent_B8A4989923779B6381A23A5C4209FD7F1E05@qq.com>
TO: Xiaoke Wang <xkernel.wang@foxmail.com>
TO: linux-kernel(a)vger.kernel.org
CC: Xiaoke Wang <xkernel.wang@foxmail.com>

Hi Xiaoke,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linux/master]
[also build test WARNING on linus/master v5.16-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Xiaoke-Wang/init-initramfs-c-check-the-return-value-of-kstrdup/20211213-170026
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 136057256686de39cc3a07c2e39ef6bc43003ff6
:::::: branch date: 12 hours ago
:::::: commit date: 12 hours ago
config: i386-randconfig-m021-20211213 (https://download.01.org/0day-ci/archive/20211214/202112140423.37WdeaEE-lkp(a)intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
init/initramfs.c:148 dir_add() error: dereferencing freed memory 'de'

Old smatch warnings:
init/initramfs.c:97 find_link() error: we previously assumed 'q' could be null (see line 95)
init/initramfs.c:142 dir_add() error: we previously assumed 'de' could be null (see line 140)

vim +/de +148 init/initramfs.c

889d51a10712b6 Nye Liu          2008-10-15  136  
e35c4c64fe492b Arnd Bergmann    2017-11-17  137  static void __init dir_add(const char *name, time64_t mtime)
889d51a10712b6 Nye Liu          2008-10-15  138  {
889d51a10712b6 Nye Liu          2008-10-15  139  	struct dir_entry *de = kmalloc(sizeof(struct dir_entry), GFP_KERNEL);
889d51a10712b6 Nye Liu          2008-10-15  140  	if (!de)
dd23e8098f33a5 Florian Fainelli 2021-02-25  141  		panic_show_mem("can't allocate dir_entry buffer");
889d51a10712b6 Nye Liu          2008-10-15  142  	de->name = kstrdup(name, GFP_KERNEL);
764baf9ece4791 Xiaoke Wang      2021-12-13  143  	if (!de->name) {
764baf9ece4791 Xiaoke Wang      2021-12-13  144  		kfree(de);
764baf9ece4791 Xiaoke Wang      2021-12-13  145  		panic_show_mem("can't duplicate dir name");
764baf9ece4791 Xiaoke Wang      2021-12-13  146  	}
764baf9ece4791 Xiaoke Wang      2021-12-13  147  	INIT_LIST_HEAD(&de->list);
889d51a10712b6 Nye Liu          2008-10-15 @148  	de->mtime = mtime;
889d51a10712b6 Nye Liu          2008-10-15  149  	list_add(&de->list, &dir_list);
889d51a10712b6 Nye Liu          2008-10-15  150  }
889d51a10712b6 Nye Liu          2008-10-15  151  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

             reply	other threads:[~2021-12-13 20:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-13 20:51 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-03-04  9:27 [PATCH] init/initramfs.c: check the return value of kstrdup() xkernel.wang
2022-03-04 14:14 ` Greg KH
2022-03-04 15:55   ` Xiaoke Wang
2022-03-07  1:28 ` Andrew Morton
2021-12-13  8:58 Xiaoke Wang

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=202112140423.37WdeaEE-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.