From: Maxime Coquelin Date: Tue, 10 Oct 2017 09:42:47 +0000 (+0200) Subject: memory: fix off-by-one error in memory_region_notify_one() X-Git-Tag: v2.11.0-rc0~41^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b021d1c04452276f4926eed2d104ccbd1037a6e1;p=thirdparty%2Fqemu.git memory: fix off-by-one error in memory_region_notify_one() This patch fixes an off-by-one error that could lead to the notifyee to receive notifications for ranges it is not registered to. The bug has been spotted by code review. Fixes: bd2bfa4c52e5 ("memory: introduce memory_region_notify_one()") Cc: qemu-stable@nongnu.org Cc: Peter Xu Signed-off-by: Maxime Coquelin Message-Id: <20171010094247.10173-4-maxime.coquelin@redhat.com> Reviewed-by: Peter Xu Signed-off-by: Paolo Bonzini --- diff --git a/memory.c b/memory.c index 5e6351a6c1c..b637c12badc 100644 --- a/memory.c +++ b/memory.c @@ -1892,7 +1892,7 @@ void memory_region_notify_one(IOMMUNotifier *notifier, * Skip the notification if the notification does not overlap * with registered range. */ - if (notifier->start > entry->iova + entry->addr_mask + 1 || + if (notifier->start > entry->iova + entry->addr_mask || notifier->end < entry->iova) { return; }