Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

CC: stable@kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

authored by

Dan Carpenter and committed by
Konrad Rzeszutek Wilk
99cb2ddc 21643e69

+1 -1
+1 -1
drivers/xen/gntalloc.c
··· 135 135 /* Grant foreign access to the page. */ 136 136 gref->gref_id = gnttab_grant_foreign_access(op->domid, 137 137 pfn_to_mfn(page_to_pfn(gref->page)), readonly); 138 - if (gref->gref_id < 0) { 138 + if ((int)gref->gref_id < 0) { 139 139 rc = gref->gref_id; 140 140 goto undo; 141 141 }