From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C160E3EC6DC; Sat, 28 Feb 2026 17:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300522; cv=none; b=Y6fdHmUnXvq9vhJ9RdPOD1ldUEHA7DO6JgmsnUb83doSMbIgAtrqmnXNzDAdvb+orIQuHYwBIpQK3HkrmMAP+P6qNDWX9FJG3H5sWoQimUWylzm2qA/z3Ysfvo8fjdLAwXUI0Qrtd9z96/yAuSaWgrY+wTsJhG/StDjN7xeXAYQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300522; c=relaxed/simple; bh=jTY4FYVwDJIGe5KfCtsL6WWiMnwR77HoDz51E9tumDY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ihityZm5nInNaECZxf7io5l+WSSwORi93ANUhrF2A5LBa7uzkLBrulFJD3NZr1gIyGhw9TO2yuw1KeKKGQH5T1TJj1/07He0lV7JlAEGvw1GeS5fdAPW2c3EzFdEK0axZNnZv0NLE/32avbObRgqYse+Alhbf1+F/VBfuQOB0/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AJckFi6P; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AJckFi6P" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1E444C19423; Sat, 28 Feb 2026 17:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300522; bh=jTY4FYVwDJIGe5KfCtsL6WWiMnwR77HoDz51E9tumDY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AJckFi6PtQekcLsrbs4r/sKGjAI3ZXmf72hqwv81OKijOQ8E2HHMlSpi+PpOwOurY WS6lxjcCBva6kPcCmfGgw9tP7wHRPLNWrvt0om4EyAIc29x8MHX8xHd13qohabOi82 fhlP9VyJlmITZWkLJ9iWDSPjo/LyJ58o+u9A9VNMxC0Q5iWcBJR9uofTLs1ELWd2t7 xGUaH6PK7ktmksLEUx9tVo8c6JUHvDibib3q0JVCD9gtJnGjIedujK2+xTzpbCYaPl 2b5NHSmC90blwnAzzKQ3Gm1XhXU3KmcNLtwBnlEil0RyMZtpBP3n+2F7JNBAsLQagz Bqvyz01v0Boug== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?G=C3=BCnther=20Noack?= , Jiri Kosina , Sasha Levin Subject: [PATCH 6.19 561/844] HID: magicmouse: Do not crash on missing msc->input Date: Sat, 28 Feb 2026 12:27:54 -0500 Message-ID: <20260228173244.1509663-562-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Günther Noack [ Upstream commit 17abd396548035fbd6179ee1a431bd75d49676a7 ] Fake USB devices can send their own report descriptors for which the input_mapping() hook does not get called. In this case, msc->input stays NULL, leading to a crash at a later time. Detect this condition in the input_configured() hook and reject the device. This is not supposed to happen with actual magic mouse devices, but can be provoked by imposing as a magic mouse USB device. Cc: stable@vger.kernel.org Signed-off-by: Günther Noack Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- drivers/hid/hid-magicmouse.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c index 7d4a25c6de0eb..91f621ceb924b 100644 --- a/drivers/hid/hid-magicmouse.c +++ b/drivers/hid/hid-magicmouse.c @@ -725,6 +725,11 @@ static int magicmouse_input_configured(struct hid_device *hdev, struct magicmouse_sc *msc = hid_get_drvdata(hdev); int ret; + if (!msc->input) { + hid_err(hdev, "magicmouse setup input failed (no input)"); + return -EINVAL; + } + ret = magicmouse_setup_input(msc->input, hdev); if (ret) { hid_err(hdev, "magicmouse setup input failed (%d)\n", ret); -- 2.51.0