]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: ims-pcu - only expose sysfs attributes on control interface
authorDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 1 Jun 2026 04:42:35 +0000 (21:42 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Sun, 7 Jun 2026 03:56:51 +0000 (20:56 -0700)
When the driver was converted to use the driver core to instantiate device
attributes (via .dev_groups in the usb_driver structure), the attributes
started appearing on all interfaces bound to the driver. Since the ims-pcu
driver manually claims the secondary data interface during probe, the
driver core automatically creates the sysfs attributes for that interface
as well.

However, the driver only supports these attributes on the primary control
interface. Data interfaces lack the necessary descriptors and internal
state to handle these requests, and accessing them can lead to unexpected
behavior or crashes.

Fix this by updating the is_visible() callbacks for both the main and OFN
attribute groups to verify that the interface being accessed is indeed the
control interface.

Fixes: 204d18a7a0c6 ("Input: ims-pcu - use driver core to instantiate device attributes")
Reported-by: Sashiko bot <sashiko-bot@kernel.org>
Assisted-by: Gemini:gemini-3.1-pro
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/ahp23lj4_vXIeUBl@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
drivers/input/misc/ims-pcu.c

index 7a1cb9333f53cb0ea594c8fd672041a60f6622b5..1383db382bc94796c1a2c89e425c5e4789f1e7f6 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/leds.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/sysfs.h>
 #include <linux/types.h>
 #include <linux/usb/input.h>
 #include <linux/usb/cdc.h>
@@ -1249,6 +1250,9 @@ static umode_t ims_pcu_is_attr_visible(struct kobject *kobj,
        struct ims_pcu *pcu = usb_get_intfdata(intf);
        umode_t mode = attr->mode;
 
+       if (intf != pcu->ctrl_intf)
+               return 0;
+
        if (pcu->bootloader_mode) {
                if (attr != &dev_attr_update_firmware_status.attr &&
                    attr != &dev_attr_update_firmware.attr &&
@@ -1488,6 +1492,9 @@ static umode_t ims_pcu_ofn_is_attr_visible(struct kobject *kobj,
        struct ims_pcu *pcu = usb_get_intfdata(intf);
        umode_t mode = attr->mode;
 
+       if (intf != pcu->ctrl_intf)
+               return SYSFS_GROUP_INVISIBLE;
+
        /*
         * PCU-B devices, both GEN_1 and GEN_2 do not have OFN sensor.
         */