public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Qiang Ma <maqianga@uniontech.com>
To: dmitry.torokhov@gmail.com, wangxiongfeng2@huawei.com
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	Qiang Ma <maqianga@uniontech.com>
Subject: [PATCH] Input: psmouse - fix psmouse detect function is a NULL pointer
Date: Wed, 19 May 2021 11:23:35 +0800	[thread overview]
Message-ID: <20210519032335.19326-1-maqianga@uniontech.com> (raw)

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




             reply	other threads:[~2021-05-19  3:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  3:23 Qiang Ma [this message]
2021-06-02  5:13 ` [PATCH] Input: psmouse - fix psmouse detect function is a NULL pointer Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210519032335.19326-1-maqianga@uniontech.com \
    --to=maqianga@uniontech.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wangxiongfeng2@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox