lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAH6sp9Ng2VUUS62eOR-KRjq5CcPeZQL9BMF1nGCD6fkiJa173w@mail.gmail.com>
Date:	Fri, 8 May 2015 12:01:49 +0200
From:	Frans Klaver <fransklaver@...il.com>
To:	Brian Norris <computersforpeace@...il.com>
Cc:	Frans Klaver <fransklaver@...il.com>,
	David Woodhouse <dwmw2@...radead.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	linux-mtd@...ts.infradead.org
Subject: Re: [PATCH 02/60] mtd: core: set some defaults when dev.parent is set

On Tue, Mar 3, 2015 at 10:39 PM, Frans Klaver <fransklaver@...il.com> wrote:
> If a parent device is set, add_mtd_device() has enough knowledge to fill
> in some sane default values for the module name and owner. Do so if they
> aren't already set.
>
> Signed-off-by: Frans Klaver <fransklaver@...il.com>
> ---
>  drivers/mtd/mtdcore.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
> index 2093676..487e467 100644
> --- a/drivers/mtd/mtdcore.c
> +++ b/drivers/mtd/mtdcore.c
> @@ -412,6 +412,15 @@ int add_mtd_device(struct mtd_info *mtd)
>         mtd->erasesize_mask = (1 << mtd->erasesize_shift) - 1;
>         mtd->writesize_mask = (1 << mtd->writesize_shift) - 1;
>
> +       if (mtd->dev.parent) {
> +               if (!mtd->owner)
> +                       mtd->owner = mtd->dev.parent->driver->owner;

Turns out that driver pointer is not guaranteed to be set. I don't
have the overview on whether this is something that only occurs with
nandsim, or whether it is possible to have an actual device without a
driver.

It is of course easy to prevent the NULL dereference, but that does
mean the requirement for owner becomes slightly more complex than
"only necessary if you don't have a parent device". Unless someone has
objections, I'll probably resend the series with this bit looking more
like

+ if (mtd->dev.parent) {
+        if (!mtd->owner && mtd->dev.parent->driver)
+                mtd->owner = ...

Nandsim seems to not have any issues with this.The drivers I've
changed to rely on this seem to all have driver set.

Thanks,
Frans
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ