From nobody Mon Feb 9 15:36:07 2026 Received: from mail-dy1-f171.google.com (mail-dy1-f171.google.com [74.125.82.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D2323E9F89 for ; Tue, 20 Jan 2026 18:14:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768932890; cv=none; b=ZAeYRp0GPhCkrHR+PSGNNvCuCNOingq1qHjcHcaFS1Oav6zARbn3Co7Ru4fMhRzGXMKdhN9NkHLUqXGLBq3filiC0wJi9+Kj7jgI87MaYLltMdWShQu4iYazK61xxbzp1Vyh75kf9fUlkk7GSXZcjQB4AUfUndUW7xm4VIapzbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768932890; c=relaxed/simple; bh=IiEQ7uyRwvRu42axOI4+B00IxhwGOcQ6YipycnmidPQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=meA/9gpP/p+zRiFfQwWSSV3A9xCMZx0t35pTz7qry6hrHClENcPT80XBSHJq/C+LfLVk0+rlr7pMr0jDU0PNv0f1qW8K2Y+DuM9xkkoeODyqKIqzxsYHuBY7rDDN/Cpbs8vb8IEgfZwHeTv1/hQ46zPfRSDKABmOVZ6o3HOaqBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SyswR/Un; arc=none smtp.client-ip=74.125.82.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SyswR/Un" Received: by mail-dy1-f171.google.com with SMTP id 5a478bee46e88-2b6f5a9cecaso2018915eec.0 for ; Tue, 20 Jan 2026 10:14:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768932888; x=1769537688; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=JvPakcMBCnGLAUdWuDHMxHBoJI9VRoMFoW9RlnxrcUg=; b=SyswR/UnYnXScE7O1ntH28uV7gaBWtOg/C9JRQLgWjoYblKTgO3TwgmKUIxLeQ4s2Z HbCWTYGgJGF09dqEyQ9jdQn69ViuShrcXbCFCTzEg28b61My7cOyB+2j4Gs2CI4kPrPT AM5/kRxdXcSzo+b8gcAw04PQ9bGq91PLTEcJaKa313H6n6z57HIIrPIYur9wSvM7hPHV Qace0wuYeHNKj5G1aONEFzBSk/uw7SPhjdFcVtkGROEhgJ9RFqMJAwHgBcAYKbqbdeWy xsKVnj7C4kDIqBkVPi6QicNoJVWyePry7RP/lr57boUvPSNtKhuUGhEuiFjOgBu50p9s FkUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768932888; x=1769537688; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JvPakcMBCnGLAUdWuDHMxHBoJI9VRoMFoW9RlnxrcUg=; b=J44N8S1CRFBXIsLXNvJbjDqk8BCgfbzhWLo0vr0+s16XrKEESpt5W/mdV/itLahnkN SR1KLq2wLTMHUHzyY++tu4QOxS7znh3dNJJwOshDBOMaHdoV3fDmrrTh4BtiRMtNNPa6 dE7HGRyAOyo+9rbbXV8in2TozwJNfg/pEnKVO76oAVZJo57gtkbvXEW18ev3ytZZecU7 8FEuN1BbOEsb6Ua+8oyr1cONUSjFDD3xxXBGDHWatlpR4cMYk4m1i2ZbGHrYp3yVuFpD nF7PdFhafSbueXbDR+hOjA1mxtTWFIPwnk8ggrYoUpoMIGeBvwr8bhUNUnICfT6ieRK6 2yOg== X-Gm-Message-State: AOJu0YzuDW+YTiojuck5NDTttJbocCzGf/WMhibNrkDYcejYv6NESjrB 1CX5a4Bnm7rT0hVd4amCyRz2hYRV6dUVZI1MBobmtueze+roa+vSwUJWu4TUfA== X-Gm-Gg: AZuq6aK0ya3Ady+11SBS9L1pOCmywFgJPqOptrfCKhmjAxqtCfVp3gUfAHybilBh/Lv xb1D3txVgkN873dDwkPUaSYPQ8YNdBdJAldnCVh4U14zvT988mrExkGsGkG9LalOe3fC2++5yFB ck0n1uw6ogGWHbJPh1l2CjIUQzLVBOsaVzKlJTTsMtA1aQgYLyXEK1aTPBMU+KBX4HsGjKmkEug u5twRsPNtQZ8rnWY8NjHmc8dbQ2VTPl9t0CK6N5b1L9I59yDB9NF1YU62TMpuOw75AXPOgTHxDO dJJo6ezuoqarefRUWLEtAEJmL43llh9GP6igtaP+r1j6/FI5SyqOnW1vT10L/NO4kKcXQOkiMIa KF9cgjjyrv2i4/sitP1NL2xx6fTTnbSlFza+K+8xLoDFBPSYv8sDI879gbOWfujp9K2DnZk6xQq rOMOtH/8e7E18wNZ1NtVbQOkY5QFlSEApCotZNWYg1es972Kzx2QTG X-Received: by 2002:a05:7300:fb94:b0:2ae:614a:3307 with SMTP id 5a478bee46e88-2b6fd7eee95mr1986031eec.42.1768932888046; Tue, 20 Jan 2026 10:14:48 -0800 (PST) Received: from google.com ([2a00:79e0:2ebe:8:d631:e554:f0bd:4106]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2b7102fd2efsm10035eec.12.2026.01.20.10.14.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 10:14:47 -0800 (PST) Date: Tue, 20 Jan 2026 10:14:45 -0800 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Haowen Tu Subject: [PATCH] Input: appletouch - fix potential race between resume and open Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Take the input device's mutex in atp_resume() and atp_recover() to make sure they are not racing with open and close methods, and use input_device_enabled() helper to see if communication with the device needs to be restarted after resume. Signed-off-by: Dmitry Torokhov --- drivers/input/mouse/appletouch.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appleto= uch.c index e669f86f1882..3ce63fb35992 100644 --- a/drivers/input/mouse/appletouch.c +++ b/drivers/input/mouse/appletouch.c @@ -200,7 +200,6 @@ struct atp { u8 *data; /* transferred data */ struct input_dev *input; /* input dev */ const struct atp_info *info; /* touchpad model */ - bool open; bool valid; /* are the samples valid? */ bool size_detect_done; bool overflow_warned; @@ -800,7 +799,6 @@ static int atp_open(struct input_dev *input) if (usb_submit_urb(dev->urb, GFP_KERNEL)) return -EIO; =20 - dev->open =3D true; return 0; } =20 @@ -810,7 +808,6 @@ static void atp_close(struct input_dev *input) =20 usb_kill_urb(dev->urb); cancel_work_sync(&dev->work); - dev->open =3D false; } =20 static int atp_handle_geyser(struct atp *dev) @@ -963,7 +960,8 @@ static int atp_recover(struct atp *dev) if (error) return error; =20 - if (dev->open && usb_submit_urb(dev->urb, GFP_KERNEL)) + guard(mutex)(&dev->input->mutex); + if (input_device_enabled(dev->input) && usb_submit_urb(dev->urb, GFP_KERN= EL)) return -EIO; =20 return 0; @@ -981,7 +979,8 @@ static int atp_resume(struct usb_interface *iface) { struct atp *dev =3D usb_get_intfdata(iface); =20 - if (dev->open && usb_submit_urb(dev->urb, GFP_KERNEL)) + guard(mutex)(&dev->input->mutex); + if (input_device_enabled(dev->input) && usb_submit_urb(dev->urb, GFP_KERN= EL)) return -EIO; =20 return 0; --=20 2.52.0.457.g6b5491de43-goog --=20 Dmitry