linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: psmouse - fix psmouse detect function is a NULL pointer
@ 2021-05-19  3:23 Qiang Ma
  2021-06-02  5:13 ` Dmitry Torokhov
  0 siblings, 1 reply; 2+ messages in thread
From: Qiang Ma @ 2021-05-19  3:23 UTC (permalink / raw)
  To: dmitry.torokhov, wangxiongfeng2; +Cc: linux-input, linux-kernel, Qiang Ma

Add a check for psmouse_do_detect(), when the detect is NULL pointer,
returning false, avoiding this possible NULL pointer exception.

Signed-off-by: Qiang Ma <maqianga@uniontech.com>
---
 drivers/input/mouse/psmouse-base.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index 0b4a3039f312..86b095728587 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -1006,6 +1006,9 @@ static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool),
 	if (set_properties)
 		psmouse_apply_defaults(psmouse);
 
+	if (!detect)
+		return false;
+
 	return detect(psmouse, set_properties) == 0;
 }
 
-- 
2.20.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Input: psmouse - fix psmouse detect function is a NULL pointer
  2021-05-19  3:23 [PATCH] Input: psmouse - fix psmouse detect function is a NULL pointer Qiang Ma
@ 2021-06-02  5:13 ` Dmitry Torokhov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2021-06-02  5:13 UTC (permalink / raw)
  To: Qiang Ma; +Cc: wangxiongfeng2, linux-input, linux-kernel

Hi Qiang,

On Wed, May 19, 2021 at 11:23:35AM +0800, Qiang Ma wrote:
> Add a check for psmouse_do_detect(), when the detect is NULL pointer,
> returning false, avoiding this possible NULL pointer exception.
> 
> Signed-off-by: Qiang Ma <maqianga@uniontech.com>
> ---
>  drivers/input/mouse/psmouse-base.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
> index 0b4a3039f312..86b095728587 100644
> --- a/drivers/input/mouse/psmouse-base.c
> +++ b/drivers/input/mouse/psmouse-base.c
> @@ -1006,6 +1006,9 @@ static bool psmouse_do_detect(int (*detect)(struct psmouse *, bool),
>  	if (set_properties)
>  		psmouse_apply_defaults(psmouse);
>  
> +	if (!detect)
> +		return false;

There are no protocols that do not define detect() method, so this
condition is not possible.

> +
>  	return detect(psmouse, set_properties) == 0;
>  }
>  

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-02  5:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-19  3:23 [PATCH] Input: psmouse - fix psmouse detect function is a NULL pointer Qiang Ma
2021-06-02  5:13 ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).