Skip to contentSkip to conversation

Fix casting usage in xen_create_msi_irq.

PATCH In review Konrad Rzeszutek Wilk 2 participants 2 messages Nov 25, 2009 – Dec 3, 2009 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix casting usage in xen_create_msi_irq.

rc is int, domid is unsigned int. The casting of negatives values to domid results in wrap where -16 becomes 0xfff0. If we check for rc (instead of domid) and find a negative value (which you can't with domid) then we will default to DOMID_SELF - which is exactly what this line was intending to do earlier but failed to do.

---
 drivers/xen/events.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/xen/events.c +1 -1
index adc8c09..67598bc 100644
@@ -678,7 +678,7 @@ int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc,
 	/* Walk the XenStore keys to see if the device is assigned to any
 	 * domain. If so, extract the domain id. */
 	domid = rc = xenbus_walk( "/local/domain/0", get_domid_for_dev, dev);
-	if (domid <= 0)
+	if (rc <= 0)
 		domid = DOMID_SELF;
 
 	memset(&map_irq, 0, sizeof(map_irq));
Signature · 1 line
1.6.2.5
Acked-by on v1 1/1
#1 lore raw

Jeremy,

Seems this fix is still not in xen/master branch, pv-ops dom0 is blocked to enable SR-IOV devices without it. Could you merge it into xen/master branch ?

Xiantao

Quoted 24 lines · Konrad Rzeszutek Wilk

rc is int, domid is unsigned int. The casting of negatives values to domid results in wrap where -16 becomes 0xfff0. If we check for rc (instead of domid) and find a negative value (which you can't with domid) then we will default to DOMID_SELF - which is exactly what this line was intending to do earlier but failed to do.

---
 drivers/xen/events.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/xen/events.c +1 -0
index adc8c09..67598bc 100644
@@ -678,7 +678,7 @@ int xen_create_msi_irq(struct pci_dev *dev,
 	struct msi_desc *msidesc, /* Walk the XenStore keys to see if the
 	 device is assigned to any * domain. If so, extract the domain id.
 	*/ domid = rc = xenbus_walk( "/local/domain/0", get_domid_for_dev,
 dev); -	if (domid <= 0)
+	if (rc <= 0)
 		domid = DOMID_SELF;
 
 	memset(&map_irq, 0, sizeof(map_irq));