Skip to contentSkip to conversation

ocxl: fix signed comparison with less than zero

PATCH Applied Colin King 4 participants 4 messages Jan 30, 2018 – Feb 9, 2018

Subsystems (3)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 ocxl: fix signed comparison with less than zero

From: Colin Ian King <[email protected]>

Currently the comparison of used < 0 is always false because uses is a size_t. Fix this by making used a ssize_t type.

Detected by Coccinelle:
drivers/misc/ocxl/file.c:320:6-10: WARNING: Unsigned expression compared with zero: used < 0

Fixes 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")
---
 drivers/misc/ocxl/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/ocxl/file.c +1 -1
index c90c1a578d2f..1287e4430e6b 100644
@@ -277,7 +277,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
 	struct ocxl_context *ctx = file->private_data;
 	struct ocxl_kernel_event_header header;
 	ssize_t rc;
-	size_t used = 0;
+	ssize_t used = 0;
 	DEFINE_WAIT(event_wait);
 
 	memset(&header, 0, sizeof(header));
Signature · 1 line
2.15.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the comparison of used < 0 is always false because uses is a size_t. Fix this by making used a ssize_t type.

Detected by Coccinelle:
drivers/misc/ocxl/file.c:320:6-10: WARNING: Unsigned expression compared with zero: used < 0

Fixes 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")

Thanks for picking this up!

Quoted 18 lines
---
  drivers/misc/ocxl/file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/ocxl/file.c +1 -1
index c90c1a578d2f..1287e4430e6b 100644
@@ -277,7 +277,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
  	struct ocxl_context *ctx = file->private_data;
  	struct ocxl_kernel_event_header header;
  	ssize_t rc;
-	size_t used = 0;
+	ssize_t used = 0;
  	DEFINE_WAIT(event_wait);
 
  	memset(&header, 0, sizeof(header));
Signature · 2 lines
Andrew Donnellan              OzLabs, ADL Canberra
[email protected]  IBM Australia Limited
Acked-by on v1 1/1
#2 lore raw
In reply to Colin King

Le 30/01/2018 à 16:11, Colin King a écrit :

Quoted 5 lines

From: Colin Ian King <[email protected]>

Currently the comparison of used < 0 is always false because uses is a size_t. Fix this by making used a ssize_t type.

Quoted 7 lines

Detected by Coccinelle:
drivers/misc/ocxl/file.c:320:6-10: WARNING: Unsigned expression compared with zero: used < 0

Fixes 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")

---

Thanks!

Quoted 17 lines
  drivers/misc/ocxl/file.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/ocxl/file.c +1 -1
index c90c1a578d2f..1287e4430e6b 100644
@@ -277,7 +277,7 @@ static ssize_t afu_read(struct file *file, char __user *buf, size_t count,
  	struct ocxl_context *ctx = file->private_data;
  	struct ocxl_kernel_event_header header;
  	ssize_t rc;
-	size_t used = 0;
+	ssize_t used = 0;
  	DEFINE_WAIT(event_wait);
 
  	memset(&header, 0, sizeof(header));
#3 lore raw
In reply to Colin King
Quoted 5 lines · Colin King

From: Colin Ian King <[email protected]>

Currently the comparison of used < 0 is always false because uses is a size_t. Fix this by making used a ssize_t type.

Quoted 8 lines

Detected by Coccinelle:
drivers/misc/ocxl/file.c:320:6-10: WARNING: Unsigned expression compared with zero: used < 0

Fixes 5ef3166e8a32 ("ocxl: Driver code for 'generic' opencapi devices")

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/dedab7f0d3137441a97fe7cf9b9ca5

cheers