• Enric Balletbo i Serra's avatar
    ASoC: rockchip-max98090: Fix NULL pointer dereference while accessing to jack. · 5f224493
    Enric Balletbo i Serra authored
    Commit f2ed6b07 ("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: default avatarEnric Balletbo i Serra <enric.balletbo@collabora.com>
    Signed-off-by: default avatarMark Brown <broonie@kernel.org>
    5f224493
rockchip_max98090.c 6.17 KB