2014-01-11 20:10:26

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand

Hi,

On Thu, Dec 26, 2013 at 10:19:39AM +0800, Huang Shijie wrote:
> On Thu, Dec 26, 2013 at 01:51:58AM +0000, Caizhiyong wrote:
> > From: Cai Zhiyong <[email protected]>
> > Date: Wed, 25 Dec 2013 21:19:21 +0800
> > Subject: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand
> >
> > This patch assigned the type->name to mtd->name when mtd->name is
> > NULL in function "find_full_id_nand".
> > mtd->name is NULL may cause some problem.
> >
> > Signed-off-by: Cai Zhiyong <[email protected]>
> Acked-by: Huang Shijie <[email protected]>

Thanks, the patch looks good. Pushed to l2-mtd.git.

Wouldn't this trigger an exception when reading
/sys/class/mtd/mtdX/name? If so, should this be marked for stable?

Brian


2014-01-13 04:14:57

by Caizhiyong

[permalink] [raw]
Subject: RE: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand

> -----Original Message-----
> From: Brian Norris [mailto:[email protected]]
> Sent: Sunday, January 12, 2014 4:10 AM
> To: Huang Shijie; Caizhiyong
> Cc: [email protected]; Wanglin (Albert); David Woodhouse;
> [email protected]; Artem Bityutskiy
> Subject: Re: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand
>
> Hi,
>
> On Thu, Dec 26, 2013 at 10:19:39AM +0800, Huang Shijie wrote:
> > On Thu, Dec 26, 2013 at 01:51:58AM +0000, Caizhiyong wrote:
> > > From: Cai Zhiyong <[email protected]>
> > > Date: Wed, 25 Dec 2013 21:19:21 +0800
> > > Subject: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand
> > >
> > > This patch assigned the type->name to mtd->name when mtd->name is
> > > NULL in function "find_full_id_nand".
> > > mtd->name is NULL may cause some problem.
> > >
> > > Signed-off-by: Cai Zhiyong <[email protected]>
> > Acked-by: Huang Shijie <[email protected]>
>
> Thanks, the patch looks good. Pushed to l2-mtd.git.
>
> Wouldn't this trigger an exception when reading
> /sys/class/mtd/mtdX/name? If so, should this be marked for stable?

View the source code, if mtd->name is NULL, cat "/sys/class/mtd/mtdX/name" will get string "(null)".

static ssize_t mtd_name_show(struct device *dev, struct device_attribute *attr, char *buf)
{
struct mtd_info *mtd = dev_get_drvdata(dev);

return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name);
}

2014-01-13 07:46:19

by Brian Norris

[permalink] [raw]
Subject: Re: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand

On Mon, Jan 13, 2014 at 04:12:45AM +0000, Caizhiyong wrote:
> > -----Original Message-----
> > From: Brian Norris [mailto:[email protected]]
> > Sent: Sunday, January 12, 2014 4:10 AM
> >
> > On Thu, Dec 26, 2013 at 10:19:39AM +0800, Huang Shijie wrote:
> > > On Thu, Dec 26, 2013 at 01:51:58AM +0000, Caizhiyong wrote:
> > > > From: Cai Zhiyong <[email protected]>
> > > > Date: Wed, 25 Dec 2013 21:19:21 +0800
> > > > Subject: [PATCH] mtd: nand: assign mtd->name in find_full_id_nand
> > > >
> > > > This patch assigned the type->name to mtd->name when mtd->name is
> > > > NULL in function "find_full_id_nand".
> > > > mtd->name is NULL may cause some problem.
> > > >
> > > > Signed-off-by: Cai Zhiyong <[email protected]>
> > > Acked-by: Huang Shijie <[email protected]>
> >
> > Thanks, the patch looks good. Pushed to l2-mtd.git.
> >
> > Wouldn't this trigger an exception when reading
> > /sys/class/mtd/mtdX/name? If so, should this be marked for stable?
>
> View the source code, if mtd->name is NULL, cat "/sys/class/mtd/mtdX/name" will get string "(null)".
>
> static ssize_t mtd_name_show(struct device *dev, struct device_attribute *attr, char *buf)
> {
> struct mtd_info *mtd = dev_get_drvdata(dev);
>
> return snprintf(buf, PAGE_SIZE, "%s\n", mtd->name);
> }

Thanks, I forgot that the kernel's printf-like functions handle NULL
pointers gracefully. In that case, this probably doesn't need to be in
-stable.

Brian