From e3509ff0fb9df53e45cd68488e3b463a80455db7 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Wed, 3 Jun 2009 17:44:49 +0200 Subject: ASoC: fix NULL pointer dereference in soc_suspend() In case the initalization of an soc_device failed, there is no codec associated with it. soc_suspend() will still dereference the pointer and cause an Ooops when entering the sleep mode. This happens on our board with a multi-target kernel image when booted on a machine without audio circuits. This patch makes the code bail out very early in this special case. Signed-off-by: Daniel Mack Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4aa8e2d3506..3f44150d8e3 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -628,6 +628,12 @@ static int soc_suspend(struct platform_device *pdev, pm_message_t state) struct snd_soc_codec *codec = card->codec; int i; + /* If the initialization of this soc device failed, there is no codec + * associated with it. Just bail out in this case. + */ + if (!codec) + return 0; + /* Due to the resume being scheduled into a workqueue we could * suspend before that's finished - wait for it to complete. */ -- cgit v1.2.3