mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: Jinjie Ruan <ruanjinjie@huawei.com>,
	linux-modules@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Luis Chamberlain <mcgrof@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] driver core: Fix a null-ptr-deref in module_add_driver()
Date: Mon, 12 Aug 2024 12:18:17 +0200	[thread overview]
Message-ID: <7ea59d03-701c-4555-a8e8-5d7272b9381c@web.de> (raw)
In-Reply-To: <20240812080658.2791982-1-ruanjinjie@huawei.com>

> Inject fault while probing of-fpga-region, if kasprintf() fails in
> module_add_driver(), the second sysfs_remove_link() in exit path will cause
> null-ptr-deref as below because kernfs_name_hash() will call strlen() with
> NULL driver_name.
…

How do you think about to use the term “null pointer dereference”
for the commit message (and summary phrase)?


…
> +++ b/drivers/base/module.c
> @@ -66,27 +66,31 @@ int module_add_driver(struct module *mod, const struct device_driver *drv)
…
>  	sysfs_remove_link(mk->drivers_dir, driver_name);
> +
> +out_free_driver_name:
>  	kfree(driver_name);
>
> +out_remove_kobj:
> +	sysfs_remove_link(&drv->p->kobj, "module");
…

I suggest to omit two blank lines here.

Regards,
Markus

  reply	other threads:[~2024-08-12 10:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12  8:06 Jinjie Ruan
2024-08-12 10:18 ` Markus Elfring [this message]
2024-08-12 10:22   ` Greg Kroah-Hartman

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=7ea59d03-701c-4555-a8e8-5d7272b9381c@web.de \
    --to=markus.elfring@web.de \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=rafael@kernel.org \
    --cc=ruanjinjie@huawei.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®