This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 7ac4991b59af78157bc854750eed23b698e547fd
Author: Marco Casaroli <[email protected]>
AuthorDate: Sun Nov 8 09:44:32 2026 +0100

    drivers/audio/audio_null: Set the playback flag of the new device.
    
    audio_null_initialize() set priv->playback after the return of the
    success path.  So the flag was never set, and every null audio device
    reported an input unit, also a device made for playback.  When
    kmm_zalloc() failed, the function wrote through a NULL pointer.
    
    Set the flag before the return.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 drivers/audio/audio_null.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/audio/audio_null.c b/drivers/audio/audio_null.c
index 9cae0137d72..58659830332 100644
--- a/drivers/audio/audio_null.c
+++ b/drivers/audio/audio_null.c
@@ -892,12 +892,11 @@ FAR struct audio_lowerhalf_s *audio_null_initialize(bool 
playback)
        * of the structure need to be initialized.
        */
 
-      priv->dev.ops = &g_audioops;
+      priv->dev.ops  = &g_audioops;
+      priv->playback = playback;
       return &priv->dev;
     }
 
-  priv->playback = playback;
-
   auderr("ERROR: Failed to allocate null audio device\n");
   return NULL;
 }

Reply via email to