[2/5] ASoC: wcd9335: fix SLIM interface device double-put on error paths

Message ID 20261107160822723MQsHLesOdU6-MJoFTSUkb@zte.com.cn (mailing list archive)
State New
Headers
Series ASoC: fix error-path leaks and a NULL dereference |

Commit Message

shao.mingyin@zte.com.cn Nov. 7, 2026, 8:08 a.m. UTC
From: Shao Mingyin <shao.mingyin@zte.com.cn>

wcd9335_slim_status() takes a reference on the SLIM interface device
with of_slim_get_device() and hands it to a devm action
(wcd9335_put_device_action), which releases it when the device is torn
down.  Four error paths also call put_device() directly, so the devm
action drops the same reference a second time at teardown and underflows
the refcount.

Drop the manual puts and let the devm action own the reference on both
the success and the failure paths.

Fixes: 082723fee626 ("ASoC: codecs: wcd9335: Fix SLIM interface device leak in wcd9335_slim_status()")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
  

Patch

diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c
index a98d1fd78925..0f8c9ccd8500 100644
--- a/sound/soc/codecs/wcd9335.c
+++ b/sound/soc/codecs/wcd9335.c
@@ -5136,7 +5136,6 @@  static int wcd9335_slim_status(struct slim_device *sdev,
 
 	wcd->regmap = regmap_init_slimbus(sdev, &wcd9335_regmap_config);
 	if (IS_ERR(wcd->regmap)) {
-		put_device(&wcd->slim_ifc_dev->dev);
 		return dev_err_probe(dev, PTR_ERR(wcd->regmap),
 				     "Failed to allocate slim register map\n");
 	}
@@ -5144,7 +5143,6 @@  static int wcd9335_slim_status(struct slim_device *sdev,
 	wcd->if_regmap = regmap_init_slimbus(wcd->slim_ifc_dev,
 						  &wcd9335_ifc_regmap_config);
 	if (IS_ERR(wcd->if_regmap)) {
-		put_device(&wcd->slim_ifc_dev->dev);
 		return dev_err_probe(dev, PTR_ERR(wcd->if_regmap),
 				     "Failed to allocate ifc register map\n");
 	}
@@ -5152,13 +5150,11 @@  static int wcd9335_slim_status(struct slim_device *sdev,
 	ret = wcd9335_bring_up(wcd);
 	if (ret) {
 		dev_err(dev, "Failed to bringup WCD9335\n");
-		put_device(&wcd->slim_ifc_dev->dev);
 		return ret;
 	}
 
 	ret = wcd9335_irq_init(wcd);
 	if (ret) {
-		put_device(&wcd->slim_ifc_dev->dev);
 		return ret;
 	}