public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Marek Vasut <marek.vasut@gmail.com>,
	Boris Brezillon <boris.brezillon@free-electrons.com>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Richard Weinberger <richard@nod.at>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux-Renesas <linux-renesas-soc@vger.kernel.org>,
	MTD Maling List <linux-mtd@lists.infradead.org>,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] mtd: partitions: Handle add_mtd_device() failures gracefully
Date: Thu, 26 Apr 2018 19:53:03 +0200	[thread overview]
Message-ID: <20180426195303.1f08d2cd@bbrezillon> (raw)
In-Reply-To: <CAMuHMdWHoxrq-tj=QznAhuZ8eC22gTTgWFi9HgyqT9pNfJFJyw@mail.gmail.com>

Hi Geert,

Sorry for the late reply.

On Tue, 10 Apr 2018 15:26:20 +0200
Geert Uytterhoeven <geert@linux-m68k.org> wrote:

> Hi Marek,
> 
> On Mon, Apr 9, 2018 at 11:59 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> > On 04/09/2018 02:25 PM, Geert Uytterhoeven wrote:  
> >> Currently add_mtd_device() failures are plainly ignored, which may lead
> >> to kernel crashes later.  
> 
> >> Fix this by ignoring and freeing partitions that failed to add in
> >> add_mtd_partitions().  The same issue is present in mtd_add_partition(),
> >> so fix that as well.
> >>
> >> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> >> ---
> >> I don't know if it is worthwhile factoring out the common handling.
> >>
> >> Should allocate_partition() fail instead?  There's a comment saying
> >> "let's register it anyway to preserve ordering".  
> 
> >> --- a/drivers/mtd/mtdpart.c
> >> +++ b/drivers/mtd/mtdpart.c  
> 
> >> @@ -746,7 +753,15 @@ int add_mtd_partitions(struct mtd_info *master,
> >>               list_add(&slave->list, &mtd_partitions);
> >>               mutex_unlock(&mtd_partitions_mutex);
> >>
> >> -             add_mtd_device(&slave->mtd);
> >> +             ret = add_mtd_device(&slave->mtd);
> >> +             if (ret) {
> >> +                     mutex_lock(&mtd_partitions_mutex);
> >> +                     list_del(&slave->list);
> >> +                     mutex_unlock(&mtd_partitions_mutex);
> >> +                     free_partition(slave);
> >> +                     continue;
> >> +             }  
> >
> > Why is the partition even in the list in the first place ? Can we avoid
> > adding it rather than adding and removing it ?  
> 
> Hence my question "Should allocate_partition() fail instead?".

I'd prefer this option too. Can you prepare a new version doing that?

Thanks,

Boris

  parent reply	other threads:[~2018-04-26 17:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-09 12:25 [PATCH] mtd: partitions: Handle add_mtd_device() failures gracefully Geert Uytterhoeven
2018-04-09 21:59 ` Marek Vasut
2018-04-10 13:26   ` Geert Uytterhoeven
2018-04-10 14:37     ` Marek Vasut
2018-04-10 14:47       ` Geert Uytterhoeven
2018-04-10 16:34         ` Steve deRosier
2018-04-26 17:53     ` Boris Brezillon [this message]
2018-04-26 17:56       ` Geert Uytterhoeven
2018-04-26 18:09         ` Boris Brezillon

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=20180426195303.1f08d2cd@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=geert+renesas@glider.be \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=marek.vasut@gmail.com \
    --cc=richard@nod.at \
    /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