Skip to contentSkip to conversation

xen-gntalloc: signedness bug in add_grefs()

PATCH In review Dan Carpenter 1 participant 1 message Nov 4, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/2 xen-gntalloc: signedness bug in add_grefs()

gref->gref_id is unsigned so the error handling didn't work. gnttab_grant_foreign_access() returns an int type, so we can add a cast here, and it doesn't cause any problems. gnttab_grant_foreign_access() can return a variety of errors including -ENOSPC, -ENOSYS and -ENOMEM.

drivers/xen/gntalloc.c +1 -1
index 23c60cf..e1c4c6e 100644
@@ -135,7 +135,7 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,
 		/* Grant foreign access to the page. */
 		gref->gref_id = gnttab_grant_foreign_access(op->domid,
 			pfn_to_mfn(page_to_pfn(gref->page)), readonly);
-		if (gref->gref_id < 0) {
+		if ((int)gref->gref_id < 0) {
 			rc = gref->gref_id;
 			goto undo;
 		}