lkml.org 
[lkml]   [2017]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v3 33/37] mtd: nand: allocate aligned buffers if NAND_OWN_BUFFERS is unset
Hi Leonard,

2017-04-06 23:08 GMT+09:00 Leonard Crestez <leonard.crestez@nxp.com>:
> On Thu, Mar 30, 2017 at 11:15 AM, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>>
>> Some NAND controllers are using DMA engine requiring a specific
>> buffer alignment. The core provides no guarantee on the nand_buffers
>> pointers, which forces some drivers to allocate their own buffers
>> and pass the NAND_OWN_BUFFERS flag.
>>
>> Rework the nand_buffers allocation logic to allocate each buffer
>> independently. This should make most NAND controllers/DMA engine
>> happy, and allow us to get rid of these custom buf allocation in
>> NAND controller drivers.
>>
>> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
>
>> @@ -4914,8 +4930,12 @@ void nand_cleanup(struct nand_chip *chip)
>> > /* Free bad block table memory */
>> kfree(chip->bbt);
>> - if (!(chip->options & NAND_OWN_BUFFERS))
>> + if (!(chip->options & NAND_OWN_BUFFERS)) {
>> + kfree(chip->buffers->databuf);
>> + kfree(chip->buffers->ecccode);
>> + kfree(chip->buffers->ecccalc);
>> kfree(chip->buffers);
>> + }
>
> It seems that chip->buffers might not be allocated at this point, for
> example if nand_cleanup is called during a failed probe. You should
> check if (chip->buffers != NULL) before freeing stuff inside it.

You are right.

The failure path in NAND drivers is messy. :-(
nand_cleanup() may be called before nand_scan_tail()
finishes successfully...

I will send a fixup patch. Thanks!



--
Best Regards
Masahiro Yamada

\
 
 \ /
  Last update: 2017-04-07 08:50    [W:0.272 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site