Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

misc: bh1770glc: use pm_runtime_resume_and_get() in power_state_store

pm_runtime_get_sync() may increment the runtime PM usage count even if the
resume fails, which requires an explicit pm_runtime_put_noidle() to balance
it. This driver ignored the return value, risking a usage-count leak on
resume failure.

Replace it with pm_runtime_resume_and_get(), which returns 0 on success and
a negative errno on failure, and only increments the usage count on success.
This simplifies the error path and avoids possible leaks. Also check for
errors explicitly with `if (ret < 0)`.

Signed-off-by: Vivek BalachandharTN <vivek.balachandhar@gmail.com>
Link: https://patch.msgid.link/20251030120022.239951-1-vivek.balachandhar@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Vivek BalachandharTN and committed by
Greg Kroah-Hartman
ef48f0f1 05d36a59

+3 -1
+3 -1
drivers/misc/bh1770glc.c
··· 640 640 641 641 mutex_lock(&chip->mutex); 642 642 if (value) { 643 - pm_runtime_get_sync(dev); 643 + ret = pm_runtime_resume_and_get(dev); 644 + if (ret < 0) 645 + goto leave; 644 646 645 647 ret = bh1770_lux_rate(chip, chip->lux_rate_index); 646 648 if (ret < 0) {