Re: [PATCH] HID: wacom: Cancel init_work when probe fails after scheduling it

From: Jason Gerecke

Date: Wed Nov 25 2026 - 18:44:15 EST


On Thu, Nov 19, 2026 at 12:29 PM Jiri Kosina <jikos@xxxxxxxxxx> wrote:
>
> On Sat, 5 Sep 2026, Aamir Ahmed wrote:
>
> > wacom_parse_and_register() schedules wacom->init_work with a one second
> > delay from wacom_query_tablet_data(), and only then opens the hardware
> > for devices with WACOM_DEVICETYPE_WL_MONITOR, that is the wireless
> > receiver's monitor interface and the ExpressKey Remote. If that
> > hid_hw_open() fails, the error path stops the hardware and releases the
> > driver's resources but leaves init_work pending.
> >
> > wacom_probe() then returns the error and the HID core releases the
> > devres group it opened around probe(), which frees the wacom structure
> > allocated with devm_kzalloc(). When init_work runs a second later,
> > wacom_init_work() derives the wacom pointer from the work item, so
> > _wacom_query_tablet_data() and wacom_led_control() read and write freed
> > memory.
> >
> > This is the only work item that can be pending at that point. The
> > others are scheduled from incoming reports, and the HID core drops
> > reports for the whole of probe() by holding driver_input_lock, which
> > this driver never releases early. The neighbouring BAMBOO_TOUCH error
> > path already cancels init_work before failing for the same reason.
> >
> > Cancel init_work on the shared error path, after hid_hw_stop() as
> > wacom_remove() does. The cancel is harmless where the work was never
> > scheduled or was already cancelled.
> >
> > Fixes: a544c619a54b ("HID: wacom: do not attempt to switch mode while in probe")
> > Reported-by: Sashiko AI <sashiko-bot@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/linux-input/20260905102908.ADE1F1F00A3D@xxxxxxxxxxxxxxx/
> > Assisted-by: LLM
> > Signed-off-by: Aamir Ahmed <elb12345@xxxxxxxxxxxxx>
>
> Ping, Jason, your review of this one would be appreciated as well. Thanks,
>
> --
> Jiri Kosina
> SUSE Labs
>

Hey Jiri,

It looks like the line added by this patch has already been accepted
as part of another commit at the tip of for-7.4/wacom:

ba16e5ffbaa1 ("HID: wacom: Advertise SW_MUTE_DEVICE capability prior
to registration")

Jason (she/they)
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....