[PATCH 5/5] Staging: ipack/devices/ipoctal: check for availability of helper functions in ipoctal_match()

From: Samuel Iglesias Gonsalvez
Date: Mon May 14 2012 - 06:53:06 EST


When installing the module, there could be a kernel oops due to a dereference of
a NULL pointer.

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@xxxxxxxxxx>
---
drivers/staging/ipack/devices/ipoctal.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/staging/ipack/devices/ipoctal.c b/drivers/staging/ipack/devices/ipoctal.c
index 7e370d3..df42b9b 100644
--- a/drivers/staging/ipack/devices/ipoctal.c
+++ b/drivers/staging/ipack/devices/ipoctal.c
@@ -799,6 +799,9 @@ static int ipoctal_match(struct ipack_device *dev)
int res;
unsigned char board_id;

+ if ((!dev->ops) || (!dev->ops->map_space) || (!dev->ops->unmap_space))
+ return -ENODEV;
+
res = dev->ops->map_space(dev, 0, IPACK_ID_SPACE);
if (res)
return res;
--
1.7.10

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/