Skip to contentSkip to conversation

ASoC: intel: Fix crash at suspend/resume without card registration

PATCH Superseded Takashi Iwai 2 participants 3 messages Nov 25, 2016

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: intel: Fix crash at suspend/resume without card registration

When ASoC Intel SST Medfield driver is probed but without codec / card assigned, it causes an Oops and freezes the kernel at suspend/resume,

PM: Suspending system (freeze)
Suspending console(s) (use no_console_suspend to debug)

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
 IP: [<ffffffffc09d9409>] sst_soc_prepare+0x19/0xa0 [snd_soc_sst_mfld_platform]
 Oops: 0000 [#1] PREEMPT SMP
 CPU: 0 PID: 1552 Comm: systemd-sleep Tainted: G W 4.9.0-rc6-1.g5f5c2ad-default #1
 Call Trace:
  [<ffffffffb45318f9>] dpm_prepare+0x209/0x460
  [<ffffffffb4531b61>] dpm_suspend_start+0x11/0x60
  [<ffffffffb40d3cc2>] suspend_devices_and_enter+0xb2/0x710
  [<ffffffffb40d462e>] pm_suspend+0x30e/0x390
  [<ffffffffb40d2eba>] state_store+0x8a/0x90
  [<ffffffffb43c670f>] kobj_attr_store+0xf/0x20
  [<ffffffffb42b0d97>] sysfs_kf_write+0x37/0x40
  [<ffffffffb42b02bc>] kernfs_fop_write+0x11c/0x1b0
  [<ffffffffb422be68>] __vfs_write+0x28/0x140
  [<ffffffffb43728a8>] ? apparmor_file_permission+0x18/0x20
  [<ffffffffb433b2ab>] ? security_file_permission+0x3b/0xc0
  [<ffffffffb422d095>] vfs_write+0xb5/0x1a0
  [<ffffffffb422e3d6>] SyS_write+0x46/0xa0
  [<ffffffffb4719fbb>] entry_SYSCALL_64_fastpath+0x1e/0xad

Add proper NULL checks in the PM code of mdfld driver.

---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +6 -0
index 25c6d87c818e..76bcb947b31c 100644
@@ -771,6 +771,9 @@ static int sst_soc_prepare(struct device *dev)
 	struct sst_data *drv = dev_get_drvdata(dev);
 	struct snd_soc_pcm_runtime *rtd;
 
+	if (!drv->soc_card)
+		return 0;
+
 	/* suspend all pcms first */
 	snd_soc_suspend(drv->soc_card->dev);
 	snd_soc_poweroff(drv->soc_card->dev);
@@ -793,6 +796,9 @@ static void sst_soc_complete(struct device *dev)
 	struct sst_data *drv = dev_get_drvdata(dev);
 	struct snd_soc_pcm_runtime *rtd;
 
+	if (!drv->soc_card)
+		return 0;
+
 	/* restart SSPs */
 	list_for_each_entry(rtd, &drv->soc_card->rtd_list, list) {
 		struct snd_soc_dai *dai = rtd->cpu_dai;
Signature · 1 line
2.10.2
#1 lore raw
Quoted 49 lines · Takashi Iwai

When ASoC Intel SST Medfield driver is probed but without codec / card assigned, it causes an Oops and freezes the kernel at suspend/resume,

PM: Suspending system (freeze)
Suspending console(s) (use no_console_suspend to debug)

 BUG: unable to handle kernel NULL pointer dereference at 0000000000000018
 IP: [<ffffffffc09d9409>] sst_soc_prepare+0x19/0xa0 [snd_soc_sst_mfld_platform]
 Oops: 0000 [#1] PREEMPT SMP
 CPU: 0 PID: 1552 Comm: systemd-sleep Tainted: G W 4.9.0-rc6-1.g5f5c2ad-default #1
 Call Trace:
  [<ffffffffb45318f9>] dpm_prepare+0x209/0x460
  [<ffffffffb4531b61>] dpm_suspend_start+0x11/0x60
  [<ffffffffb40d3cc2>] suspend_devices_and_enter+0xb2/0x710
  [<ffffffffb40d462e>] pm_suspend+0x30e/0x390
  [<ffffffffb40d2eba>] state_store+0x8a/0x90
  [<ffffffffb43c670f>] kobj_attr_store+0xf/0x20
  [<ffffffffb42b0d97>] sysfs_kf_write+0x37/0x40
  [<ffffffffb42b02bc>] kernfs_fop_write+0x11c/0x1b0
  [<ffffffffb422be68>] __vfs_write+0x28/0x140
  [<ffffffffb43728a8>] ? apparmor_file_permission+0x18/0x20
  [<ffffffffb433b2ab>] ? security_file_permission+0x3b/0xc0
  [<ffffffffb422d095>] vfs_write+0xb5/0x1a0
  [<ffffffffb422e3d6>] SyS_write+0x46/0xa0
  [<ffffffffb4719fbb>] entry_SYSCALL_64_fastpath+0x1e/0xad

Add proper NULL checks in the PM code of mdfld driver.

---
 sound/soc/intel/atom/sst-mfld-platform-pcm.c | 6 ++++++
 1 file changed, 6 insertions(+)
sound/soc/intel/atom/sst-mfld-platform-pcm.c +3 -0
index 25c6d87c818e..76bcb947b31c 100644
@@ -771,6 +771,9 @@ static int sst_soc_prepare(struct device *dev)
 	struct sst_data *drv = dev_get_drvdata(dev);
 	struct snd_soc_pcm_runtime *rtd;
 
+	if (!drv->soc_card)
+		return 0;
+
 	/* suspend all pcms first */
 	snd_soc_suspend(drv->soc_card->dev);
 	snd_soc_poweroff(drv->soc_card->dev);

sound/soc/intel/atom/sst-mfld-platform-pcm.c static void sst_soc_complete(struct device *dev) · line 800

Quoted 5 lines
sound/soc/intel/atom/sst-mfld-platform-pcm.c +2 -0
@@ -793,6 +796,9 @@ static void sst_soc_complete(struct device *dev)
 	struct sst_data *drv = dev_get_drvdata(dev);
 	struct snd_soc_pcm_runtime *rtd;
 
+	if (!drv->soc_card)
+		return 0;

My bad, this is a void function, the return value should be omitted. Will respin the patch soon...

Takashi

#2 lore raw
In reply to Takashi Iwai
reproduce:

Hi Takashi,

[auto build test WARNING on asoc/for-next]
[also build test WARNING on v4.9-rc6 next-20161125]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Takashi-Iwai/ASoC-intel-Fix-crash-at-suspend-resume-without-card-registration/20161126-054456
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-i0-201647 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

sound/soc/intel/atom/sst-mfld-platform-pcm.c: In function 'sst_soc_complete':

>> sound/soc/intel/atom/sst-mfld-platform-pcm.c:800:3: warning: 'return' with a value, in function returning void
      return 0;
      ^

vim +/return +800 sound/soc/intel/atom/sst-mfld-platform-pcm.c

784
785 if (dai->active) {
786 send_ssp_cmd(dai, dai->name, 0);
787 sst_handle_vb_timer(dai, false);
788 }
789 }
790
791 return 0;
792 }
793
794 static void sst_soc_complete(struct device *dev)
795 {
796 struct sst_data *drv = dev_get_drvdata(dev);
797 struct snd_soc_pcm_runtime *rtd;
798
799 if (!drv->soc_card)

 > 800			return 0;

801
802 /* restart SSPs */
803 list_for_each_entry(rtd, &drv->soc_card->rtd_list, list) {
804 struct snd_soc_dai *dai = rtd->cpu_dai;
805
806 if (dai->active) {
807 sst_handle_vb_timer(dai, true);
808 send_ssp_cmd(dai, dai->name, 1);

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation