mfd: check for NULL platform data
PATCH 1/1 mfd: check for NULL platform data
Avoid kernel crash if platform data is NULL.
--- drivers/mfd/mc13xxx-core.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/mfd/mc13xxx-core.c +3 -0
@@ -757,6 +757,9 @@ err_revision:mc13xxx_unlock (mc13xxx); +if (pdata ==NULL ) +return 0 ; +if (pdata->flags &MC13XXX_USE_ADC )mc13xxx_add_subdevice (mc13xxx,"%s-adc" );
Signature · 1 line
1.6.0.4
Hi Fabio,
Quoted 12 lines · Fabio Estevam
Avoid kernel crash if platform data is NULL.
Signed-off-by Fabio Estevam <[email protected]>--- drivers/mfd/mc13xxx-core.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/mfd/mc13xxx-core.c +0
-0
drivers/mfd/mc13xxx-core.c err_revision: · line 762
Quoted 6 lines
drivers/mfd/mc13xxx-core.c +3
-0@@ -757,6 +757,9 @@ err_revision:mc13xxx_unlock (mc13xxx); +if (pdata ==NULL ) +return 0 ; +
I'm not sure it's really needed to catch this error. Not passing pdata isn't sensible and then maybe failing with a bang is better than handling silently.
And if you want to break probing, do you really want to return 0, i.e. let the binding succeed? IMHO (if you really want to handle pdata == NULL) you should fail before allocating the private data with -ESOMETHINGSENSIBLE.
Thanks,
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
Hi Uwe,
Quoted 25 lines · Uwe Kleine-König
Hi Fabio,
Quoted 12 lines · Fabio Estevam
Avoid kernel crash if platform data is NULL.
Signed-off-by Fabio Estevam <[email protected]>--- drivers/mfd/mc13xxx-core.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)drivers/mfd/mc13xxx-core.c +0
-0drivers/mfd/mc13xxx-core.c err_revision: · line 762
Quoted 6 lines
drivers/mfd/mc13xxx-core.c +3
-0@@ -757,6 +757,9 @@ err_revision:mc13xxx_unlock (mc13xxx); +if (pdata ==NULL ) +return 0 ; +I'm not sure it's really needed to catch this error. Not passing pdata isn't sensible and then maybe failing with a bang is better than handling silently.
Quoted 4 lines
And if you want to break probing, do you really want to return 0, i.e. let the binding succeed? IMHO (if you really want to handle pdata == NULL) you should fail before allocating the private data with
-ESOMETHINGSENSIBLE.
Agreed. Besides failing silently, Fabio's patch leaks the mc13xxx pointer and doesn't free the requested IRQ line.
So NAK for now, although I wouldn't be against checking for a NULL pdata at the very begining of the probe routine.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/