Re: [PATCH] input: pm8xxx-vibrator: fix a potential NULL pointer dereference

2019-04-26 Thread Dmitry Torokhov
Hi Kangjie,

On Fri, Mar 08, 2019 at 11:39:21PM -0600, Kangjie Lu wrote:
> In case of_device_get_match_data fails to find the matched data,
> returns -ENODEV

How can this happen? We will not match again the device if compatible is
not present in the table.

If this happens I'd rather we crash and burn instead of silently
ignoring the failure.

Thanks.

> 
> Signed-off-by: Kangjie Lu 
> ---
>  drivers/input/misc/pm8xxx-vibrator.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/input/misc/pm8xxx-vibrator.c 
> b/drivers/input/misc/pm8xxx-vibrator.c
> index 7dd1c1fbe42a..740e59c11808 100644
> --- a/drivers/input/misc/pm8xxx-vibrator.c
> +++ b/drivers/input/misc/pm8xxx-vibrator.c
> @@ -196,6 +196,8 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
>   vib->vib_input_dev = input_dev;
>  
>   regs = of_device_get_match_data(>dev);
> + if (unlikely(!regs))
> + return -ENODEV;
>  
>   /* operate in manual mode */
>   error = regmap_read(vib->regmap, regs->drv_addr, );
> -- 
> 2.17.1
> 

-- 
Dmitry


[PATCH] input: pm8xxx-vibrator: fix a potential NULL pointer dereference

2019-03-22 Thread Kangjie Lu
In case of_device_get_match_data fails to find the matched data,
returns -ENODEV

Signed-off-by: Kangjie Lu 
---
 drivers/input/misc/pm8xxx-vibrator.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/misc/pm8xxx-vibrator.c 
b/drivers/input/misc/pm8xxx-vibrator.c
index 7dd1c1fbe42a..740e59c11808 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -196,6 +196,8 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
vib->vib_input_dev = input_dev;
 
regs = of_device_get_match_data(>dev);
+   if (unlikely(!regs))
+   return -ENODEV;
 
/* operate in manual mode */
error = regmap_read(vib->regmap, regs->drv_addr, );
-- 
2.17.1



[PATCH] input: pm8xxx-vibrator: fix a potential NULL pointer dereference

2019-03-08 Thread Kangjie Lu
In case of_device_get_match_data fails to find the matched data,
returns -ENODEV

Signed-off-by: Kangjie Lu 
---
 drivers/input/misc/pm8xxx-vibrator.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/misc/pm8xxx-vibrator.c 
b/drivers/input/misc/pm8xxx-vibrator.c
index 7dd1c1fbe42a..740e59c11808 100644
--- a/drivers/input/misc/pm8xxx-vibrator.c
+++ b/drivers/input/misc/pm8xxx-vibrator.c
@@ -196,6 +196,8 @@ static int pm8xxx_vib_probe(struct platform_device *pdev)
vib->vib_input_dev = input_dev;
 
regs = of_device_get_match_data(>dev);
+   if (unlikely(!regs))
+   return -ENODEV;
 
/* operate in manual mode */
error = regmap_read(vib->regmap, regs->drv_addr, );
-- 
2.17.1