xen/pvcalls: Fix a check in pvcalls_front_remove()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 5 Dec 2017 14:38:54 +0000 (17:38 +0300)
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>
Wed, 6 Dec 2017 14:44:49 +0000 (09:44 -0500)
bedata->ref can't be less than zero because it's unsigned.  This affects
certain error paths in probe.  We first set ->ref = -1 and then we set
it to a valid value later.

Fixes: 219681909913 ("xen/pvcalls: connect to the backend")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
drivers/xen/pvcalls-front.c

index afa3f1b5d807646dc949b410b1f00c327b9825fb..d1e1d8d2b9d545b00eb87085b6f941f04900cd74 100644 (file)
@@ -1103,7 +1103,7 @@ static int pvcalls_front_remove(struct xenbus_device *dev)
                        kfree(map);
                }
        }
-       if (bedata->ref >= 0)
+       if (bedata->ref != -1)
                gnttab_end_foreign_access(bedata->ref, 0, 0);
        kfree(bedata->ring.sring);
        kfree(bedata);