Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1446582

Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl

From Richard Weinberger <richard@nod.at>
Newsgroups linux.kernel
Subject Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl
Date 2016-07-19 18:10 +0200
Message-ID <rWFKO-6cr-29@gated-at.bofh.it> (permalink)
References <rWFrr-5Qf-3@gated-at.bofh.it> <rWFrr-5Qf-11@gated-at.bofh.it> <rWFB9-5U4-39@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Am 19.07.2016 um 17:59 schrieb Boris Brezillon:
> On Tue, 19 Jul 2016 17:44:48 +0200
> Richard Weinberger <richard@nod.at> wrote:
> 
>> Am 19.07.2016 um 17:41 schrieb Andrey Smirnov:
>>> If no user specified chip->select_chip() function is provided, code in
>>> nand_base.c will automatically set this hook to nand_select_chip(),
>>> which in turn depends on chip->cmd_ctrl() hook being valid. Not
>>> providing both of those functions in NAND controller driver (for example
>>> by mistake) will result in a bit cryptic segfault. Replace it with
>>> explicit BUG_ON statement so it would be obvious what went wrong.
>>>
>>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>>> ---
>>>  drivers/mtd/nand/nand_base.c | 4 +++-
>>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
>>> index ce7b2ca..57043a6 100644
>>> --- a/drivers/mtd/nand/nand_base.c
>>> +++ b/drivers/mtd/nand/nand_base.c
>>> @@ -3128,8 +3128,10 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
>>>  	if (chip->waitfunc == NULL)
>>>  		chip->waitfunc = nand_wait;
>>>  
>>> -	if (!chip->select_chip)
>>> +	if (!chip->select_chip) {
>>> +		BUG_ON(!chip->cmd_ctrl);  
>>
>> Please don't add new BUG_ON() calls. WARN_ON() is good enough to raise the driver developer's
>> attention and won't kill the machine.
> 
> Not sure a BUG_ON() is worst than a NULL-pointer exception ;-).

When this really just triggers a NULL-pointer exception, we don't need a BUG_ON or WARN_ON at
all since the kernel can tell anyway what went wrong.

From the patch description I thought it is a more cryptic problem...

Thanks,
//richard

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Richard Weinberger <richard@nod.at> - 2016-07-19 17:50 +0200
  Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 18:00 +0200
    Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Richard Weinberger <richard@nod.at> - 2016-07-19 18:10 +0200
      Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 18:20 +0200
        Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Richard Weinberger <richard@nod.at> - 2016-07-19 18:30 +0200
          Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Andrey Smirnov <andrew.smirnov@gmail.com> - 2016-07-19 20:20 +0200
            Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 20:20 +0200
              Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Brian Norris <computersforpeace@gmail.com> - 2016-07-19 20:30 +0200
                Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and cmd_ctrl Andrey Smirnov <andrew.smirnov@gmail.com> - 2016-07-19 20:40 +0200
        Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Brian Norris <computersforpeace@gmail.com> - 2016-07-19 20:20 +0200
          Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Boris Brezillon <boris.brezillon@free-electrons.com> - 2016-07-19 20:50 +0200
            Re: [PATCH 1/2] mtd: nand: BUG_ON in case of no select_chip and  cmd_ctrl Brian Norris <computersforpeace@gmail.com> - 2016-07-19 21:40 +0200

csiph-web