Skip to content

Commit f0dfdcb

Browse files
jhovoldbroonie
authored andcommitted
ASoC: codecs: wcd938x-sdw: fix use after free on driver unbind
Make sure to deregister the component when the driver is being unbound and before the underlying device-managed resources are freed. Fixes: 1657252 ("ASoC: codecs: wcd938x-sdw: add SoundWire driver") Cc: [email protected] # 5.14 Cc: Srinivas Kandagatla <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 3ebebb2 commit f0dfdcb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sound/soc/codecs/wcd938x-sdw.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,15 @@ static int wcd9380_probe(struct sdw_slave *pdev,
12811281
return component_add(dev, &wcd938x_sdw_component_ops);
12821282
}
12831283

1284+
static int wcd9380_remove(struct sdw_slave *pdev)
1285+
{
1286+
struct device *dev = &pdev->dev;
1287+
1288+
component_del(dev, &wcd938x_sdw_component_ops);
1289+
1290+
return 0;
1291+
}
1292+
12841293
static const struct sdw_device_id wcd9380_slave_id[] = {
12851294
SDW_SLAVE_ENTRY(0x0217, 0x10d, 0),
12861295
{},
@@ -1320,6 +1329,7 @@ static const struct dev_pm_ops wcd938x_sdw_pm_ops = {
13201329

13211330
static struct sdw_driver wcd9380_codec_driver = {
13221331
.probe = wcd9380_probe,
1332+
.remove = wcd9380_remove,
13231333
.ops = &wcd9380_slave_ops,
13241334
.id_table = wcd9380_slave_id,
13251335
.driver = {

0 commit comments

Comments
 (0)