Skip to content

Commit 97af544

Browse files
jhovoldbroonie
authored andcommitted
ASoC: codecs: pm4125: clean up bind() device reference handling
A recent change fixed a couple of device leaks on component bind failure and on unbind but did so in a confusing way by adding misleading initialisations at bind() and bogus NULL checks at unbind(). Cc: Ma Ke <make24@iscas.ac.cn> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Link: https://patch.msgid.link/20251219142412.19043-1-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent a0c8ee0 commit 97af544

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

sound/soc/codecs/pm4125.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,10 +1505,6 @@ static int pm4125_bind(struct device *dev)
15051505
struct device_link *devlink;
15061506
int ret;
15071507

1508-
/* Initialize device pointers to NULL for safe cleanup */
1509-
pm4125->rxdev = NULL;
1510-
pm4125->txdev = NULL;
1511-
15121508
/* Give the soundwire subdevices some more time to settle */
15131509
usleep_range(15000, 15010);
15141510

@@ -1624,11 +1620,8 @@ static void pm4125_unbind(struct device *dev)
16241620
device_link_remove(dev, pm4125->rxdev);
16251621
device_link_remove(pm4125->rxdev, pm4125->txdev);
16261622

1627-
/* Release device references acquired in bind */
1628-
if (pm4125->txdev)
1629-
put_device(pm4125->txdev);
1630-
if (pm4125->rxdev)
1631-
put_device(pm4125->rxdev);
1623+
put_device(pm4125->txdev);
1624+
put_device(pm4125->rxdev);
16321625

16331626
component_unbind_all(dev, pm4125);
16341627
}

0 commit comments

Comments
 (0)