From: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
To: jikos@kernel.org, jic23@kernel.org, bentiss@kernel.org
Cc: linux-input@vger.kernel.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org, simeon@maryasin.name,
lixu.zhang@intel.com, crofts@kernel.org,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Subject: [PATCH v3 6/7] HID: sensor: custom: Register enable attribute after misc device
Date: Mon, 9 Nov 2026 11:59:48 -0800 [thread overview]
Message-ID: <20261109195949.384888-7-srinivas.pandruvada@linux.intel.com> (raw)
In-Reply-To: <20261109195949.384888-1-srinivas.pandruvada@linux.intel.com>
Register the enable_sensor sysfs group only after misc-device setup
succeeds. This prevents userspace from opening the sensor hub while
probe can still fail, which would otherwise leave the hub open reference
unbalanced on unwind.
Fixes: 4a7de0519df5 ("HID: sensor: Custom and Generic sensor support")
Reported-by: Semyon Maryasin <simeon@maryasin.name>
Closes: https://lore.kernel.org/all/CAM2dg7ewfVJSP4rFyhkCB1Rmd1+X56sAg=eUdbPthG2xrLqwQQ@mail.gmail.com/
Tested-by: Semyon Maryasin <simeon@maryasin.name>
Tested-by: Zhang Lixu <lixu.zhang@intel.com>
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/hid/hid-sensor-custom.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid-sensor-custom.c
index 55698dea5b86..8a71e86d247b 100644
--- a/drivers/hid/hid-sensor-custom.c
+++ b/drivers/hid/hid-sensor-custom.c
@@ -1059,20 +1059,19 @@ static int hid_sensor_custom_probe(struct platform_device *pdev)
if (ret)
goto err_remove_callback;
- ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
- &enable_sensor_attr_group);
+ ret = hid_sensor_custom_dev_if_add(sensor_inst);
if (ret)
goto err_remove_attributes;
- ret = hid_sensor_custom_dev_if_add(sensor_inst);
+ ret = sysfs_create_group(&sensor_inst->pdev->dev.kobj,
+ &enable_sensor_attr_group);
if (ret)
- goto err_remove_group;
+ goto err_remove_dev_if;
return 0;
-err_remove_group:
- sysfs_remove_group(&sensor_inst->pdev->dev.kobj,
- &enable_sensor_attr_group);
+err_remove_dev_if:
+ hid_sensor_custom_dev_if_remove(sensor_inst);
err_remove_attributes:
hid_sensor_custom_remove_attributes(sensor_inst);
err_remove_callback:
--
2.56.0
next prev parent reply other threads:[~2026-11-09 19:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 19:59 [PATCH v3 0/7] HID: sensor: custom: use-after-free after remove Srinivas Pandruvada
2026-11-09 19:59 ` [PATCH v3 1/7] HID: sensor-hub: Synchronize callback removal with raw events Srinivas Pandruvada
2026-11-09 19:59 ` [PATCH v3 2/7] HID: sensor: custom: Set owner for misc device Srinivas Pandruvada
2026-11-09 19:59 ` [PATCH v3 3/7] HID: sensor: custom: Disable sensor before hub close on removal Srinivas Pandruvada
2026-11-09 19:59 ` [PATCH v3 4/7] HID: sensor: custom: Fix state lifetime during removal Srinivas Pandruvada
2026-11-09 19:59 ` [PATCH v3 5/7] HID: sensor: custom: Serialize misc device reads Srinivas Pandruvada
2026-11-09 19:59 ` Srinivas Pandruvada [this message]
2026-11-09 19:59 ` [PATCH v3 7/7] HID: sensor-hub: Remove clients before stopping hardware Srinivas Pandruvada
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=20261109195949.384888-7-srinivas.pandruvada@linux.intel.com \
--to=srinivas.pandruvada@linux.intel.com \
--cc=bentiss@kernel.org \
--cc=crofts@kernel.org \
--cc=jic23@kernel.org \
--cc=jikos@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lixu.zhang@intel.com \
--cc=simeon@maryasin.name \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®