diff mbox series

[1/3] audio: fix parameter dereference before NULL check

Message ID 0eadcc88b8421bb86ce2d68ac70517f920c3ad6c.1568157545.git.DirtY.iCE.hu@gmail.com
State New
Headers show
Series Audio: misc fixes for "Audio 20190821 patches", part two | expand

Commit Message

=?UTF-8?B?Wm9sdMOhbiBLxZF2w6Fnw7M=?= Sept. 10, 2019, 11:26 p.m. UTC
This should fix Coverity issues CID 1405305 and 1405301.

Signed-off-by: Kővágó, Zoltán <DirtY.iCE.hu@gmail.com>
---
 audio/audio_template.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/audio/audio_template.h b/audio/audio_template.h
index 2562bf5f00..cc4b53b5d7 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -428,8 +428,8 @@  SW *glue (AUD_open_, TYPE) (
     struct audsettings *as
     )
 {
-    AudioState *s = card->state;
-    AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
+    AudioState *s;
+    AudiodevPerDirectionOptions *pdo;
 
     if (audio_bug(__func__, !card || !name || !callback_fn || !as)) {
         dolog ("card=%p name=%p callback_fn=%p as=%p\n",
@@ -437,6 +437,9 @@  SW *glue (AUD_open_, TYPE) (
         goto fail;
     }
 
+    s = card->state;
+    pdo = glue(audio_get_pdo_, TYPE)(s->dev);
+
     ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",
             name, as->freq, as->nchannels, as->fmt);