All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Input: psmouse: add NULL check to psmouse_from_serio()
Date: Fri,  5 Apr 2024 10:44:46 +0200	[thread overview]
Message-ID: <20240405084448.15754-1-tiwai@suse.de> (raw)

The serio drvdata can be still NULL while the PS/2 interrupt is
processed.  This leaded to crash with a NULL dereference Oops, as
psmouse_from_serio() blindly assumes the non-NULL ps2dev object.

Add a NULL check and return NULL from psmouse_from_serio().  The
returned NULL is handled properly in the caller side, skipping the
rest gracefully.

The log in the bugzilla entry showed that the probe of synaptics
driver succeeded after that point.  So this is a stop-gap solution.

Link: https://bugzilla.suse.com/show_bug.cgi?id=1219522
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---

 drivers/input/mouse/psmouse-base.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
index a0aac76b1e41..fdeee7578d18 100644
--- a/drivers/input/mouse/psmouse-base.c
+++ b/drivers/input/mouse/psmouse-base.c
@@ -120,6 +120,8 @@ struct psmouse *psmouse_from_serio(struct serio *serio)
 {
 	struct ps2dev *ps2dev = serio_get_drvdata(serio);
 
+	if (!ps2dev)
+		return NULL;
 	return container_of(ps2dev, struct psmouse, ps2dev);
 }
 
-- 
2.43.0


                 reply	other threads:[~2024-04-05  8:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240405084448.15754-1-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.