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

xiaoxiang pushed a commit to branch releases/12.2
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/12.2 by this push:
     new 0dba857028 drivers/sensors/apds9960.c: Fix resource leak in error 
handling
0dba857028 is described below

commit 0dba857028ba3b9285d92a68c3aefad04cf87e46
Author: Mingjie Shen <shen...@purdue.edu>
AuthorDate: Sun Jun 25 23:29:15 2023 -0400

    drivers/sensors/apds9960.c: Fix resource leak in error handling
    
    Signed-off-by: Mingjie Shen <shen...@purdue.edu>
---
 drivers/sensors/apds9960.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/sensors/apds9960.c b/drivers/sensors/apds9960.c
index aa97c345cf..40df1935d9 100644
--- a/drivers/sensors/apds9960.c
+++ b/drivers/sensors/apds9960.c
@@ -1218,6 +1218,7 @@ int apds9960_register(FAR const char *devpath,
   if (ret != OK)
     {
       snerr("ERROR: APDS-9960 is not responding!\n");
+      kmm_free(priv);
       return ret;
     }
 
@@ -1227,6 +1228,7 @@ int apds9960_register(FAR const char *devpath,
   if (ret < 0)
     {
       snerr("ERROR: Failed to initialize the APDS9960!\n");
+      kmm_free(priv);
       return ret;
     }
 
@@ -1240,6 +1242,7 @@ int apds9960_register(FAR const char *devpath,
   if (ret < 0)
     {
       snerr("ERROR: Failed to initialize the APDS9960!\n");
+      kmm_free(priv);
       return ret;
     }
 
@@ -1249,6 +1252,7 @@ int apds9960_register(FAR const char *devpath,
   if (ret < 0)
     {
       snerr("ERROR: Failed to initialize the APDS9960!\n");
+      kmm_free(priv);
       return ret;
     }
 
@@ -1262,6 +1266,7 @@ int apds9960_register(FAR const char *devpath,
   if (ret < 0)
     {
       snerr("ERROR: Failed to write APDS9960_GCONFIG4!\n");
+      kmm_free(priv);
       return ret;
     }
 
@@ -1271,6 +1276,7 @@ int apds9960_register(FAR const char *devpath,
   if (ret < 0)
     {
       snerr("ERROR: Failed to initialize the APDS9960!\n");
+      kmm_free(priv);
       return ret;
     }
 

Reply via email to