Skip to contentSkip to conversation

kvm: coalesced_mmio: remove one redundant check inside of coalesced_mmio_in_range()

PATCH In review Tiejun Chen 2 participants 4 messages Dec 11, 2014 – Dec 12, 2014 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kvm: coalesced_mmio: remove one redundant check inside of coalesced_mmio_in_range()

We already check 'len' above to make sure it already isn't negative here, so indeed, (addr + len < addr) should never be happened.

---
 virt/kvm/coalesced_mmio.c | 2 --
 1 file changed, 2 deletions(-)
virt/kvm/coalesced_mmio.c +0 -2
index 00d8642..60f59cd 100644
@@ -30,8 +30,6 @@ static int coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev,
 	 */
 	if (len < 0)
 		return 0;
-	if (addr + len < addr)
-		return 0;
 	if (addr < dev->zone.addr)
 		return 0;
 	if (addr + len > dev->zone.addr + dev->zone.size)
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 2 lines · Tiejun Chen

We already check 'len' above to make sure it already isn't negative here, so indeed, (addr + len < addr) should never be happened.

... except if there is an overflow.

Paolo

Quoted 19 lines
---
 virt/kvm/coalesced_mmio.c | 2 --
 1 file changed, 2 deletions(-)
virt/kvm/coalesced_mmio.c +0 -2
index 00d8642..60f59cd 100644
@@ -30,8 +30,6 @@ static int coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev,
 	 */
 	if (len < 0)
 		return 0;
-	if (addr + len < addr)
-		return 0;
 	if (addr < dev->zone.addr)
 		return 0;
 	if (addr + len > dev->zone.addr + dev->zone.size)
#2 lore raw
Quoted 7 lines · Paolo Bonzini
Quoted 2 lines · Tiejun Chen

We already check 'len' above to make sure it already isn't negative here, so indeed, (addr + len < addr) should never be happened.

... except if there is an overflow.

Sorry, I'm confused. 'addr' is u64 and now 'len' would always be '>=0', what's your a so-called overflow here? And we also have such a check below, (addr + len > dev->zone.addr + dev->zone.size), so can this guarantee an overflow?

Thanks
Tiejun

Quoted 27 lines

Paolo

Quoted 11 lines
---
  virt/kvm/coalesced_mmio.c | 2 --
  1 file changed, 2 deletions(-)
virt/kvm/coalesced_mmio.c +0 -0
index 00d8642..60f59cd 100644

virt/kvm/coalesced_mmio.c static int coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev, · line 35

Quoted 8 lines
virt/kvm/coalesced_mmio.c +0 -2
@@ -30,8 +30,6 @@ static int coalesced_mmio_in_range(struct kvm_coalesced_mmio_dev *dev,
  	 */
  	if (len < 0)
  		return 0;
-	if (addr + len < addr)
-		return 0;
  	if (addr < dev->zone.addr)
  		return 0;
  	if (addr + len > dev->zone.addr + dev->zone.size)

--
To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 9 lines · Tiejun
Quoted 7 lines · Paolo Bonzini
Quoted 2 lines · Tiejun Chen

We already check 'len' above to make sure it already isn't negative here, so indeed, (addr + len < addr) should never be happened.

... except if there is an overflow.

I think now I can understand what you mean.

Thanks
Tiejun