Skip to content

Commit 99cb2dd

Browse files
Dan Carpenterkonradwilk
authored andcommitted
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>
1 parent 21643e6 commit 99cb2dd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/xen/gntalloc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static int add_grefs(struct ioctl_gntalloc_alloc_gref *op,
135135
/* Grant foreign access to the page. */
136136
gref->gref_id = gnttab_grant_foreign_access(op->domid,
137137
pfn_to_mfn(page_to_pfn(gref->page)), readonly);
138-
if (gref->gref_id < 0) {
138+
if ((int)gref->gref_id < 0) {
139139
rc = gref->gref_id;
140140
goto undo;
141141
}

0 commit comments

Comments
 (0)