From 3344697afc8a6efcd24f5148c7031ac5ac085639 Mon Sep 17 00:00:00 2001 From: Mingjie Shen Date: Sun, 25 Jun 2023 23:29:15 -0400 Subject: [PATCH] drivers/sensors/apds9960.c: Fix resource leak in error handling Signed-off-by: Mingjie Shen --- 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; }