From: Geert Uytterhoeven Date: Tue, 13 Jan 2015 20:03:37 +0000 (+0100) Subject: ASoC: simple-card: Fix crash in asoc_simple_card_unref() X-Git-Tag: omap-for-v4.1/prcm-dts-mfd-syscon-fix~214^2~1^2^3 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ddfdb5c5a5b51bdd2cb749d8341d763b079d520;p=pandora-kernel.git ASoC: simple-card: Fix crash in asoc_simple_card_unref() If asoc_simple_card_probe() fails, asoc_simple_card_unref() may be called before dev_set_drvdata(), causing a NULL pointer dereference in asoc_simple_card_unref(): Unable to handle kernel NULL pointer dereference at virtual address 000000d4 ... PC is at asoc_simple_card_unref+0x14/0x48 LR is at asoc_simple_card_probe+0x3d4/0x40c This typically happens because asoc_simple_card_parse_of() returns -EPROBE_DEFER, but other failure modes are possible. devm_snd_soc_register_card()/snd_soc_register_card() may fail either before or after dev_set_drvdata(). Pass a snd_soc_card pointer instead of a platform_device pointer to asoc_simple_card_unref() to fix this. Note that if CONFIG_OF_DYNAMIC=n, of_node_put() is a dummy, and gcc may optimize away the loop over card->dai_link, never actually dereferencing card, and thus avoiding the crash... Signed-off-by: Geert Uytterhoeven Fixes: e512e001dafa54e5 ("ASoC: simple-card: Fix the reference count of device nodes") Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- Reading git-diff-tree failed