Message ID | 20190709114251.24662-1-dkirjanov@suse.com |
---|---|
State | Rejected |
Delegated to: | David Miller |
Headers | show |
Series | vhost: fix null pointer dereference in vhost_del_umem_range | expand |
From: Denis Kirjanov <kda@linux-powerpc.org> Date: Tue, 9 Jul 2019 13:42:51 +0200 > @@ -962,7 +962,8 @@ static void vhost_del_umem_range(struct vhost_umem *umem, > > while ((node = vhost_umem_interval_tree_iter_first(&umem->umem_tree, > start, end))) > - vhost_umem_free(umem, node); > + if (node) > + vhost_umem_free(umem, node); If 'node' is NULL we will not be in the body of the loop as per the while() condition. How did you test this?
On 7/9/19, David Miller <davem@davemloft.net> wrote: > From: Denis Kirjanov <kda@linux-powerpc.org> > Date: Tue, 9 Jul 2019 13:42:51 +0200 > >> @@ -962,7 +962,8 @@ static void vhost_del_umem_range(struct vhost_umem >> *umem, >> >> while ((node = vhost_umem_interval_tree_iter_first(&umem->umem_tree, >> start, end))) >> - vhost_umem_free(umem, node); >> + if (node) >> + vhost_umem_free(umem, node); > > If 'node' is NULL we will not be in the body of the loop as per > the while() condition. The patch is incorrect, please ignore > > How did you test this? >
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e995c12d8e24..026123a6fc7b 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -962,7 +962,8 @@ static void vhost_del_umem_range(struct vhost_umem *umem, while ((node = vhost_umem_interval_tree_iter_first(&umem->umem_tree, start, end))) - vhost_umem_free(umem, node); + if (node) + vhost_umem_free(umem, node); } static void vhost_iotlb_notify_vq(struct vhost_dev *d,