Skip to content

Commit

Permalink
xen-gntalloc: signedness bug in add_grefs()
Browse files Browse the repository at this point in the history
commit 99cb2dd upstream.

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.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Nov 21, 2011
1 parent 1b4f3a2 commit 8bb72ab
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/xen/gntalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8bb72ab

Please sign in to comment.