drivers/sensors/apds9960.c: Fix use after free

Memory pointed by priv may be used (in line 1289) after it is
freed in line 1283.
Fix by adding the missing return statement in error handling.

Signed-off-by: Mingjie Shen <shen497@purdue.edu>
This commit is contained in:
Mingjie Shen 2023-06-24 23:19:49 -04:00 committed by Xiang Xiao
parent 9603288c80
commit 209bee3266
1 changed files with 1 additions and 0 deletions

View File

@ -1281,6 +1281,7 @@ int apds9960_register(FAR const char *devpath,
{ {
snerr("ERROR: Failed to register driver: %d\n", ret); snerr("ERROR: Failed to register driver: %d\n", ret);
kmm_free(priv); kmm_free(priv);
return ret;
} }
/* Attach to the interrupt */ /* Attach to the interrupt */