From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 B4DDC3F935C for ; Sat, 28 Feb 2026 19:10:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772305829; cv=none; b=PcIL7s8QzHuy7U6N6mzvoIcofw39c9rI0XOL+yOumwgoMej6qfQldiCHMDQX0YxzCYSf5ZxOehmfHlsiqUS4oVZclGP0Q9hXylXJW1RA8AQWv3rLk5IxkZ0OytoM2cFIWFEqufIFD2gdjaONMAwR9UNTLPtumGAhTyVC1GPuLr0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772305829; c=relaxed/simple; bh=ahbdmih7WQ0iTC46oVpFlRhVysCbDuhJxLFvU0ArxBg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eRm9GhEMxkne7WqB8pq51cMzAUApYaRVRo/c9b6abF7AeLZa9KbQZkuh1LHu+kEJQ74HgSvGnc2mOql4KKUknMHWi8j2WBOzU2U2mvJpDKgcml9NlAWpKMdulORgCOSHuaGpl1aopRLFjWlisSc0nUxVIhtS2D+Zu9A3Biyc1gY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tiP5O7oC; arc=none smtp.client-ip=91.218.175.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tiP5O7oC" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1772305826; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1stq13byh5E4uEMWZJeQMnQj/VCCrTTUyF6+AOc0Hyc=; b=tiP5O7oCvLJIr3J+H24Yb0BWjcIR4SlXluOqY1p2XMgkqUyp4F05tGSqfu+2KXlob9uZbi rnnvjLInVJ3kUxjdKoGMA46LWjhc8vFp4JtIYEtASSzqQEwVi8Kd03RvCHWLOxo/OtdozB LXml4ZfJ3jaMFHyQDItkySbxVYMrIqc= From: Denis Benato To: linux-kernel@vger.kernel.org Cc: linux-input@vger.kernel.org, "Benjamin Tissoires" , "Jiri Kosina" , "Luke D . Jones" , "Mateusz Schyboll" , "Denis Benato" , "Denis Benato" Subject: [PATCH v2 6/7] HID: asus: do not abort probe when not necessary Date: Sat, 28 Feb 2026 20:10:09 +0100 Message-ID: <20260228191010.3830758-7-denis.benato@linux.dev> In-Reply-To: <20260228191010.3830758-1-denis.benato@linux.dev> References: <20260228191010.3830758-1-denis.benato@linux.dev> Precedence: bulk X-Mailing-List: linux-input@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT In order to avoid dereferencing a NULL pointer asus_probe is aborted early and control of some asus devices is transferred over hid-generic after erroring out even when such NULL dereference cannot happen: only early abort when the NULL dereference can happen. Also make the code shorter and more adherent to coding standards removing square brackets enclosing single-line if-else statements. Fixes: d3af6ca9a8c3 ("HID: asus: fix UAF via HID_CLAIMED_INPUT validation") Signed-off-by: Denis Benato --- drivers/hid/hid-asus.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c index 4fa8e72c6855..5780e70aebd5 100644 --- a/drivers/hid/hid-asus.c +++ b/drivers/hid/hid-asus.c @@ -1323,22 +1323,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id) * were freed during registration due to no usages being mapped, * leaving drvdata->input pointing to freed memory. */ - if (!drvdata->input || !(hdev->claimed & HID_CLAIMED_INPUT)) { - hid_err(hdev, "Asus input not registered\n"); - ret = -ENOMEM; - goto err_stop_hw; - } - - if (drvdata->tp) { - drvdata->input->name = "Asus TouchPad"; - } else { - drvdata->input->name = "Asus Keyboard"; - } + if (drvdata->input && (hdev->claimed & HID_CLAIMED_INPUT)) { + if (drvdata->tp) + drvdata->input->name = "Asus TouchPad"; + else + drvdata->input->name = "Asus Keyboard"; - if (drvdata->tp) { - ret = asus_start_multitouch(hdev); - if (ret) - goto err_stop_hw; + if (drvdata->tp) { + ret = asus_start_multitouch(hdev); + if (ret) + goto err_stop_hw; + } } return 0; -- 2.53.0