OSDN Git Service

ASoC: rockchip-max98090: Fix NULL pointer dereference while accessing to jack.
authorEnric Balletbo i Serra <enric.balletbo@collabora.com>
Mon, 9 May 2016 10:46:31 +0000 (12:46 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 30 May 2016 15:19:41 +0000 (16:19 +0100)
commit5f22449344d9db35bcaf19c8e1bb4062188aeb09
tree87623603e93df5a9932e0f63597a48dd60edbfda
parent170abcaae8bec0a53f2f7708a83119ec42fb09e2
ASoC: rockchip-max98090: Fix NULL pointer dereference while accessing to jack.

Commit f2ed6b07645e ("ASoC: Make aux_dev more like a generic
component") caused a regression on this driver, since now a
kernel oops is seen when rockchip-mac98090 driver is loaded.

That commit changed the probing of aux_devs before checking
new DAI links, so for this driver rk_98090_headset_init is
called before rk_init and then the kernel oops due a NULL
pointer dereference inside rk_98090_headset_init function
since there is a call that tries to access the jack pointer
which has not been allocated yet.

This is the call chain that causes the crash:

 rk_98090_headset_init
   -> ts3a227e_enable_jack_detect
      -> snd_jack_set_key
 rk_init
   -> snd_soc_card_jack_new

This patch moves the new jack object creation from rk_init
to rk_98090_headset_init function making sure the jack is
created before is accessed.

Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/rockchip/rockchip_max98090.c