lkml.org 
[lkml]   [2018]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] mtd: partitions: Handle add_mtd_device() failures gracefully
Hi Marek,

On Tue, Apr 10, 2018 at 4:37 PM, Marek Vasut <marek.vasut@gmail.com> wrote:
> On 04/10/2018 03:26 PM, Geert Uytterhoeven wrote:
>> 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?".
>> Note that if we go that route, it should be a "soft" failure, as we
>> probably don't
>> want to drop all other partitions on the device.
> Is the number of partitions ie. in /proc/mtdparts an ABI ?

I don't know.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

\
 
 \ /
  Last update: 2018-04-10 16:47    [W:0.115 / U:1.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site