sony-laptop: fix potential improper handle usage
Subsystems (2)
PATCH 1/1 sony-laptop: fix potential improper handle usage
SNC handles are positive numbers, all handles are valid with the sole exception of handle 0x0. This patch fixes sony_find_snc_handle, now using unsigned int for the handle variable and returning -1 when argument its value is 0x0.
Signed-off-by Marco Chiappero <[email protected]>
---
drivers/platform/x86/sony-laptop.c +3 -3
@@ -811,12 +811,12 @@ static int sony_nc_handles_cleanup(strucreturn 0 ; } -static int sony_find_snc_handle (int handle) +static int sony_find_snc_handle (unsigned int handle) {int i; -/* not initialized yet, return early */ -if (!handles) +/* not initialized yet or invalid handle, return early */ +if (!handles || !handle)return -1 ;for (i =0 ; i <0x10 ; i++) {