[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 02 Feb 2012 16:12:13 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Richard Purdie <rpurdie@...ys.net>,
"Milo(Woogyom) Kim" <milo.kim@...com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH 1/2] backlight: lp855x_bl: Checking platform data in
lp855x_probe
The reset of the code assumes pdata is not NULL.
Add checking for pdata in lp855x_probe, this prevents NULL dereference if pdata
is NULL.
Signed-off-by: Axel Lin <axel.lin@...il.com>
---
drivers/video/backlight/lp855x_bl.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 8f628b8..5ab9ec8 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -230,9 +230,14 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
{
struct lp855x *lp;
struct lp855x_platform_data *pdata = cl->dev.platform_data;
- enum lp855x_brightness_ctrl_mode mode = pdata->mode;
+ enum lp855x_brightness_ctrl_mode mode;
int ret;
+ if (!pdata) {
+ dev_err(&cl->dev, "no platform data supplied\n");
+ return -EINVAL;
+ }
+
if (!i2c_check_functionality(cl->adapter, I2C_FUNC_SMBUS_I2C_BLOCK))
return -EIO;
@@ -240,6 +245,7 @@ static int lp855x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
if (!lp)
return -ENOMEM;
+ mode = pdata->mode;
lp->client = cl;
lp->dev = &cl->dev;
lp->pdata = pdata;
--
1.7.5.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists