[PATCH] sony-laptop: fix potential improper handle usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <marco@xxxxxxxxxx>
---

--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -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++) {
--
To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux