ASoC: Intel: Skylake: Fix substream dereference before check
authorVinod Koul <vinod.koul@intel.com>
Fri, 30 Oct 2015 15:04:20 +0000 (20:34 +0530)
committerMark Brown <broonie@kernel.org>
Mon, 16 Nov 2015 10:08:09 +0000 (10:08 +0000)
Smatch warns that we dereferenced substream before check, so fix
this by initializing ebus after the check

sound/soc/intel/skylake/skl-pcm.c:802 skl_get_position()
        warn: variable dereferenced before check 'substream->runtime'

Reported by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-pcm.c

index 2517ec5..e652d58 100644 (file)
@@ -807,7 +807,7 @@ static unsigned int skl_get_position(struct hdac_ext_stream *hstream,
 {
        struct hdac_stream *hstr = hdac_stream(hstream);
        struct snd_pcm_substream *substream = hstr->substream;
-       struct hdac_ext_bus *ebus = get_bus_ctx(substream);
+       struct hdac_ext_bus *ebus;
        unsigned int pos;
        int delay;
 
@@ -818,6 +818,7 @@ static unsigned int skl_get_position(struct hdac_ext_stream *hstream,
                pos = 0;
 
        if (substream->runtime) {
+               ebus = get_bus_ctx(substream);
                delay = skl_get_delay_from_lpib(ebus, hstream, pos)
                                                 + codec_delay;
                substream->runtime->delay += delay;