Skip to content

Commit 1abbf80

Browse files
mszyprowgregkh
authored andcommitted
Input: max8997-haptic - fix NULL pointer dereference
commit 6ae645d upstream. NULL pointer derefence happens when booting with DTB because the platform data for haptic device is not set in supplied data from parent MFD device. The MFD device creates only platform data (from Device Tree) for itself, not for haptic child. Unable to handle kernel NULL pointer dereference at virtual address 0000009c pgd = c0004000 [0000009c] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM (max8997_haptic_probe) from [<c03f9cec>] (platform_drv_probe+0x4c/0xb0) (platform_drv_probe) from [<c03f8440>] (driver_probe_device+0x214/0x2c0) (driver_probe_device) from [<c03f8598>] (__driver_attach+0xac/0xb0) (__driver_attach) from [<c03f67ac>] (bus_for_each_dev+0x68/0x9c) (bus_for_each_dev) from [<c03f7a38>] (bus_add_driver+0x1a0/0x218) (bus_add_driver) from [<c03f8db0>] (driver_register+0x78/0xf8) (driver_register) from [<c0101774>] (do_one_initcall+0x90/0x1d8) (do_one_initcall) from [<c0a00dbc>] (kernel_init_freeable+0x15c/0x1fc) (kernel_init_freeable) from [<c06bb5b4>] (kernel_init+0x8/0x114) (kernel_init) from [<c0107938>] (ret_from_fork+0x14/0x3c) Signed-off-by: Marek Szyprowski <[email protected]> Fixes: 104594b ("Input: add driver support for MAX8997-haptic") [k.kozlowski: Write commit message, add CC-stable] Signed-off-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 007796c commit 1abbf80

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/input/misc/max8997_haptic.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,14 @@ static int max8997_haptic_probe(struct platform_device *pdev)
255255
struct max8997_dev *iodev = dev_get_drvdata(pdev->dev.parent);
256256
const struct max8997_platform_data *pdata =
257257
dev_get_platdata(iodev->dev);
258-
const struct max8997_haptic_platform_data *haptic_pdata =
259-
pdata->haptic_pdata;
258+
const struct max8997_haptic_platform_data *haptic_pdata = NULL;
260259
struct max8997_haptic *chip;
261260
struct input_dev *input_dev;
262261
int error;
263262

263+
if (pdata)
264+
haptic_pdata = pdata->haptic_pdata;
265+
264266
if (!haptic_pdata) {
265267
dev_err(&pdev->dev, "no haptic platform data\n");
266268
return -EINVAL;

0 commit comments

Comments
 (0)