Skip to content

Commit

Permalink
mfd: Check for twl4030-madc NULL pointer
Browse files Browse the repository at this point in the history
If the twl4030-madc device wasn't registered, and another device, such
as twl4030-madc-hwmon, calls twl4030_madc_conversion() a NULL pointer is
dereferenced.

Signed-off-by: Kyle Manna <kyle@kylemanna.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Kyle Manna authored and Samuel Ortiz committed Sep 6, 2011
1 parent 66cc5b8 commit d0e84ca
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/mfd/twl4030-madc.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,9 @@ int twl4030_madc_conversion(struct twl4030_madc_request *req)
u8 ch_msb, ch_lsb;
int ret;

if (!req)
if (!req || !twl4030_madc)
return -EINVAL;

mutex_lock(&twl4030_madc->lock);
if (req->method < TWL4030_MADC_RT || req->method > TWL4030_MADC_SW2) {
ret = -EINVAL;
Expand Down

0 comments on commit d0e84ca

Please sign in to comment.