From: Marcus Cooper <[email protected]>

The A23 SDK has additional parameter checks to ensure that
null pointers are not being used.

Signed-off-by: Marcus Cooper <[email protected]>
---
 sound/soc/sunxi/hdmiaudio/sndhdmi.c         |  4 ++++
 sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c | 10 ++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sunxi/hdmiaudio/sndhdmi.c 
b/sound/soc/sunxi/hdmiaudio/sndhdmi.c
index 90cbe87..1c306d2 100644
--- a/sound/soc/sunxi/hdmiaudio/sndhdmi.c
+++ b/sound/soc/sunxi/hdmiaudio/sndhdmi.c
@@ -68,6 +68,10 @@ static int sndhdmi_hw_params(struct snd_pcm_substream 
*substream,
                                struct snd_pcm_hw_params *params,
                                struct snd_soc_dai *dai)
 {
+       if ((!substream) || (!params)) {
+               printk("error:%s,line:%d\n", __func__, __LINE__);
+               return -EAGAIN;
+       }
        hdmi_para.sample_rate = params_rate(params);
        hdmi_para.channel_num = params_channels(params);
        switch (params_format(params)) {
diff --git a/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c 
b/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
index 4fc296d..12da1a6 100644
--- a/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
+++ b/sound/soc/sunxi/hdmiaudio/sunxi-hdmiaudio.c
@@ -56,10 +56,16 @@ static int sunxi_hdmiaudio_hw_params(struct 
snd_pcm_substream *substream,
                                        struct snd_pcm_hw_params *params,
                                        struct snd_soc_dai *dai)
 {
-       struct snd_soc_pcm_runtime *rtd = substream->private_data;
+       struct snd_soc_pcm_runtime *rtd;
        struct sunxi_dma_params *dma_data;
 
-       /* play or record */
+       if (!substream) {
+               printk("error:%s,line:%d\n", __func__, __LINE__);
+               return -EAGAIN;
+       }
+
+       rtd = substream->private_data;
+
        if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
                dma_data = &sunxi_hdmiaudio_pcm_stereo_out;
        else
-- 
1.8.3.2

-- 
You received this message because you are subscribed to the Google Groups 
"linux-sunxi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to