All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Uddhav Swami" <uddhavswami@gmail.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH] HID: add driver for Gigabyte Aero vendor-specific brightness keys
Date: Wed, 15 Jul 2026 01:08:08 +0000	[thread overview]
Message-ID: <20260715010809.35A881F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715004457.100650-1-uddhavswami@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Dangling pointer in `drvdata->input` leads to Use-After-Free if `hidinput_connect()` fails during device probe.
--

--- Patch [1]: [PATCH] HID: add driver for Gigabyte Aero vendor-specific brightness keys ---
commit 1b9632575a5f9cf3b6d4d94e30945e582cc34a94
Author: Uddhav Swami <uddhavswami@gmail.com>

    HID: add driver for Gigabyte Aero vendor-specific brightness keys

This commit adds a minimal HID driver that intercepts vendor-defined HID
reports for the Gigabyte Aero 15 XB keyboard. It maps values 0x7D and 0x7E
to KEY_BRIGHTNESSDOWN and KEY_BRIGHTNESSUP respectively.

> diff --git a/drivers/hid/hid-gigabyte.c b/drivers/hid/hid-gigabyte.c
> new file mode 100644
> index 0000000000000..1c242734aed3f
> --- /dev/null
> +++ b/drivers/hid/hid-gigabyte.c
> @@ -0,0 +1,127 @@

[ ... ]

> +static int gigabyte_aero_input_configured(struct hid_device *hdev,
> +					  struct hid_input *hi)
> +{
> +	struct gigabyte_drvdata *drvdata = hid_get_drvdata(hdev);
> +	struct input_dev *input = hi->input;
> +
> +	input_set_capability(input, EV_KEY, KEY_BRIGHTNESSUP);
> +	input_set_capability(input, EV_KEY, KEY_BRIGHTNESSDOWN);
> +
> +	drvdata->input = input;

[Severity: High]
Can drvdata->input become a dangling pointer here if input registration fails?

If hidinput_connect() fails later during the probe sequence (for example, if
input_register_device() fails), hidinput_disconnect() will be called and it
frees the input_dev.

However, because this driver implements a .raw_event callback, hid_connect()
will still return success. This allows hid_hw_start() to return 0 and the
probe to complete successfully.

If that happens, drvdata->input is left pointing to the freed input_dev,
which will trigger a use-after-free in gigabyte_aero_raw_event() when a
brightness key is pressed:

	case GIGABYTE_AERO_BRIGHTNESS_DOWN:
		input_report_key(drvdata->input, KEY_BRIGHTNESSDOWN, 1);

Could we avoid this by checking if (hdev->claimed & HID_CLAIMED_INPUT) is
set after hid_hw_start() completes in gigabyte_aero_probe()?

> +
> +	return 0;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260715004457.100650-1-uddhavswami@gmail.com?part=1

  reply	other threads:[~2026-07-15  1:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15  0:44 [PATCH] HID: add driver for Gigabyte Aero vendor-specific brightness keys Uddhav Swami
2026-07-15  1:08 ` sashiko-bot [this message]
2026-07-15  4:15 ` [PATCH v2] " Uddhav Swami
2026-07-15  4:27   ` sashiko-bot
2026-07-15  5:59 ` [PATCH v3] " Uddhav Swami

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260715010809.35A881F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=uddhavswami@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.