* [PATCH] make ds1wm driver to check ds1wm_platform_data pointer against NULL @ 2007-11-09 6:07 eric miao 2007-11-10 1:02 ` Andrew Morton 0 siblings, 1 reply; 4+ messages in thread From: eric miao @ 2007-11-09 6:07 UTC (permalink / raw) To: linux-kernel; +Cc: Szabolcs Gyurko Do a sanity check for the "struct ds1wm_platform_data" pointer passed in by the platform_device, and so to enforce each platform to provide a valid structure. Signed-off-by: eric miao <eric.miao@marvell.com> --- drivers/w1/masters/ds1wm.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c index 5747997..11ce9ec 100644 --- a/drivers/w1/masters/ds1wm.c +++ b/drivers/w1/masters/ds1wm.c @@ -351,6 +351,10 @@ static int ds1wm_probe(struct platform_device *pdev) goto err0; } plat = pdev->dev.platform_data; + if (!plat) { + ret = -ENXIO; + goto err0; + } ds1wm_data->bus_shift = plat->bus_shift; ds1wm_data->pdev = pdev; ds1wm_data->pdata = plat; -- 1.5.2.5.GIT ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] make ds1wm driver to check ds1wm_platform_data pointer against NULL 2007-11-09 6:07 [PATCH] make ds1wm driver to check ds1wm_platform_data pointer against NULL eric miao @ 2007-11-10 1:02 ` Andrew Morton 2007-11-10 17:08 ` Evgeniy Polyakov 0 siblings, 1 reply; 4+ messages in thread From: Andrew Morton @ 2007-11-10 1:02 UTC (permalink / raw) To: eric miao; +Cc: linux-kernel, szabolcs.gyurko, Evgeniy Polyakov On Fri, 9 Nov 2007 14:07:31 +0800 "eric miao" <eric.y.miao@gmail.com> wrote: > Do a sanity check for the "struct ds1wm_platform_data" pointer passed in > by the platform_device, and so to enforce each platform to provide a > valid structure. > > Signed-off-by: eric miao <eric.miao@marvell.com> > --- > drivers/w1/masters/ds1wm.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/drivers/w1/masters/ds1wm.c b/drivers/w1/masters/ds1wm.c > index 5747997..11ce9ec 100644 > --- a/drivers/w1/masters/ds1wm.c > +++ b/drivers/w1/masters/ds1wm.c > @@ -351,6 +351,10 @@ static int ds1wm_probe(struct platform_device *pdev) > goto err0; > } > plat = pdev->dev.platform_data; > + if (!plat) { > + ret = -ENXIO; > + goto err0; > + } > ds1wm_data->bus_shift = plat->bus_shift; > ds1wm_data->pdev = pdev; > ds1wm_data->pdata = plat; I don't understand this change. Could you please provide some more details regarding what problem it is solving? How can pdev->dev.platform_data==NULL come about? Thanks. ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] make ds1wm driver to check ds1wm_platform_data pointer against NULL 2007-11-10 1:02 ` Andrew Morton @ 2007-11-10 17:08 ` Evgeniy Polyakov 2007-11-11 2:26 ` eric miao 0 siblings, 1 reply; 4+ messages in thread From: Evgeniy Polyakov @ 2007-11-10 17:08 UTC (permalink / raw) To: Andrew Morton; +Cc: eric miao, linux-kernel, szabolcs.gyurko On Fri, Nov 09, 2007 at 05:02:38PM -0800, Andrew Morton (akpm@linux-foundation.org) wrote: > > @@ -351,6 +351,10 @@ static int ds1wm_probe(struct platform_device *pdev) > > goto err0; > > } > > plat = pdev->dev.platform_data; > > + if (!plat) { > > + ret = -ENXIO; > > + goto err0; > > + } > > ds1wm_data->bus_shift = plat->bus_shift; > > ds1wm_data->pdev = pdev; > > ds1wm_data->pdata = plat; > > I don't understand this change. Could you please provide some more details > regarding what problem it is solving? How can pdev->dev.platform_data==NULL > come about? If I understood correctly, it is posible to call platform's probe callback without previously calling platform_device_add_data() to setup platform_data. But actually I failed to find any user of this platform driver in vanilla kernel, so it is hard to say if driver is used properly or not by external modules, and thus this change is very likely valid. -- Evgeniy Polyakov ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] make ds1wm driver to check ds1wm_platform_data pointer against NULL 2007-11-10 17:08 ` Evgeniy Polyakov @ 2007-11-11 2:26 ` eric miao 0 siblings, 0 replies; 4+ messages in thread From: eric miao @ 2007-11-11 2:26 UTC (permalink / raw) To: Evgeniy Polyakov; +Cc: Andrew Morton, linux-kernel, szabolcs.gyurko On Nov 11, 2007 1:08 AM, Evgeniy Polyakov <johnpol@2ka.mipt.ru> wrote: > On Fri, Nov 09, 2007 at 05:02:38PM -0800, Andrew Morton (akpm@linux-foundation.org) wrote: > > > @@ -351,6 +351,10 @@ static int ds1wm_probe(struct platform_device *pdev) > > > goto err0; > > > } > > > plat = pdev->dev.platform_data; > > > + if (!plat) { > > > + ret = -ENXIO; > > > + goto err0; > > > + } > > > ds1wm_data->bus_shift = plat->bus_shift; > > > ds1wm_data->pdev = pdev; > > > ds1wm_data->pdata = plat; > > > > I don't understand this change. Could you please provide some more details > > regarding what problem it is solving? How can pdev->dev.platform_data==NULL > > come about? > > If I understood correctly, it is posible to call platform's probe > callback without previously calling platform_device_add_data() to setup > platform_data. > > But actually I failed to find any user of this platform driver in > vanilla kernel, so it is hard to say if driver is used properly or not > by external modules, and thus this change is very likely valid. > > -- > Evgeniy Polyakov > Yes, that's exactly what this patch meant to prevent. That no use of this platform driver in vanilla kernel doesn't mean the check is unnecessary. Actually, from the code of this driver, the platform_data is mandatory for the driver to work properly. Well, if an oops is on purpose when platform_data == NULL, this is, I agree, completely unnecessary. -- Cheers - eric ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-11-11 2:26 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-11-09 6:07 [PATCH] make ds1wm driver to check ds1wm_platform_data pointer against NULL eric miao 2007-11-10 1:02 ` Andrew Morton 2007-11-10 17:08 ` Evgeniy Polyakov 2007-11-11 2:26 ` eric miao
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox