From 390ea57569fcb16782234a231c479db03329fdac Mon Sep 17 00:00:00 2001 From: Libin Yang Date: Tue, 9 Mar 2021 17:28:50 +0800 Subject: [PATCH] ASoC: SOF: check sdev in snd_sof_device_shutdown SOF driver may not be probed successfully and sdev is NULL. We should check sdev before using it in shutdown. Signed-off-by: Libin Yang --- sound/soc/sof/core.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c index 495295a34c3a69..1e867b28867c90 100644 --- a/sound/soc/sof/core.c +++ b/sound/soc/sof/core.c @@ -400,6 +400,15 @@ int snd_sof_device_shutdown(struct device *dev) { struct snd_sof_dev *sdev = dev_get_drvdata(dev); + /* + * Let's check if the sdev is valid or not. + * If probe is not completed and sdev is NULL, + * it means audio is not enabled and we should skip + * the shutdown. + */ + if (!sdev) + return 0; + return snd_sof_shutdown(sdev); } EXPORT_SYMBOL(snd_sof_device_shutdown);