Skip to contentSkip to conversation

sony-laptop: fix potential improper handle usage

PATCH Superseded Marco Chiappero 1 participant 1 message Jun 8, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

---

drivers/platform/x86/sony-laptop.c +3 -3
@@ -811,12 +811,12 @@ static int sony_nc_handles_cleanup(struc
 	return 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++) {