All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"Uwe Kleine-König (The Capable Hub)"
	<u.kleine-koenig@baylibre.com>, "Dan Murphy" <dmurphy@ti.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 08/10] Input: drv2667 - disable haptics work across suspend and resume
Date: Fri, 27 Nov 2026 20:10:02 +0000	[thread overview]
Message-ID: <20261127201050.3532488-9-lee@kernel.org> (raw)
In-Reply-To: <20261127201050.3532488-1-lee@kernel.org>

drv2667_suspend() puts the device into standby and disables its
regulator without stopping haptics->work.  A pending or timer-scheduled
haptics worker can therefore execute I2C regmap transactions while the
chip is unpowered or the I2C bus is suspended, including when the input
device is inhibited.

Call disable_work_sync() unconditionally in drv2667_suspend() before
entering standby (re-enabling on suspend error) and call enable_work()
unconditionally in drv2667_resume() so the disable count always remains
balanced across suspend/resume cycles.

Fixes: 1c24622572d6 ("Input: add support for the DRV2667 haptic driver")
Closes: https://sashiko.dev/#/bug/linux-b8ddefd2-393d-487e-8c76-2dbc5ef46b64
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/input/misc/drv2667.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/input/misc/drv2667.c b/drivers/input/misc/drv2667.c
index 18cf689d7ef7..3326aeb9874e 100644
--- a/drivers/input/misc/drv2667.c
+++ b/drivers/input/misc/drv2667.c
@@ -405,12 +405,15 @@ static int drv2667_suspend(struct device *dev)
 
 	guard(mutex)(&haptics->input_dev->mutex);
 
+	disable_work_sync(&haptics->work);
+
 	if (input_device_enabled(haptics->input_dev)) {
 		error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
 					   DRV2667_STANDBY, DRV2667_STANDBY);
 		if (error) {
 			dev_err(dev, "Failed to set standby mode\n");
 			regulator_disable(haptics->regulator);
+			enable_work(&haptics->work);
 			return error;
 		}
 
@@ -420,6 +423,7 @@ static int drv2667_suspend(struct device *dev)
 			regmap_update_bits(haptics->regmap,
 					   DRV2667_CTRL_2,
 					   DRV2667_STANDBY, 0);
+			enable_work(&haptics->work);
 			return error;
 		}
 	}
@@ -430,7 +434,7 @@ static int drv2667_suspend(struct device *dev)
 static int drv2667_resume(struct device *dev)
 {
 	struct drv2667_data *haptics = dev_get_drvdata(dev);
-	int error;
+	int error = 0;
 
 	guard(mutex)(&haptics->input_dev->mutex);
 
@@ -438,7 +442,7 @@ static int drv2667_resume(struct device *dev)
 		error = regulator_enable(haptics->regulator);
 		if (error) {
 			dev_err(dev, "Failed to enable regulator\n");
-			return error;
+			goto out;
 		}
 
 		error = regmap_update_bits(haptics->regmap, DRV2667_CTRL_2,
@@ -446,12 +450,13 @@ static int drv2667_resume(struct device *dev)
 		if (error) {
 			dev_err(dev, "Failed to unset standby mode\n");
 			regulator_disable(haptics->regulator);
-			return error;
+			goto out;
 		}
-
 	}
 
-	return 0;
+out:
+	enable_work(&haptics->work);
+	return error;
 }
 
 static DEFINE_SIMPLE_DEV_PM_OPS(drv2667_pm_ops, drv2667_suspend, drv2667_resume);
-- 
2.56.1.839.g22a8290db9-goog


  parent reply	other threads:[~2026-11-27 20:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
2026-11-30  5:42   ` Dmitry Torokhov
2026-11-27 20:09 ` [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode() Lee Jones
2026-11-30  5:42   ` Dmitry Torokhov
2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
2026-11-27 20:24   ` sashiko-bot
2026-11-27 20:09 ` [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work Lee Jones
2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
2026-11-27 20:35   ` David Heidelberg
2026-11-28  6:09   ` Dmitry Torokhov
2026-11-27 20:10 ` [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing Lee Jones
2026-11-30  6:04   ` Dmitry Torokhov
2026-11-27 20:10 ` [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume Lee Jones
2026-11-27 20:10 ` Lee Jones [this message]
2026-11-27 20:10 ` [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL Lee Jones
2026-11-27 20:10 ` [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size Lee Jones
2026-11-29  6:27   ` Dmitry Torokhov

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=20261127201050.3532488-9-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=dmurphy@ti.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.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.