From: Michael S. Tsirkin Date: Tue, 14 Oct 2014 23:52:31 +0000 (+1030) Subject: virtio_net: fix use after free on allocation failure X-Git-Tag: v4.9.8~5504^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=024655555021e971203c519770609509e0af4468;p=platform%2Fkernel%2Flinux-rpi3.git virtio_net: fix use after free on allocation failure In the extremely unlikely event that driver initialization fails after RX buffers are added, virtio net frees RX buffers while VQs are still active, potentially causing device to use a freed buffer. To fix, reset device first - same as we do on device removal. Signed-off-by: Michael S. Tsirkin Reviewed-by: Cornelia Huck Signed-off-by: Rusty Russell --- diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index aba7b93..53031e5 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c @@ -1830,6 +1830,8 @@ static int virtnet_probe(struct virtio_device *vdev) return 0; free_recv_bufs: + vi->vdev->config->reset(vdev); + free_receive_bufs(vi); unregister_netdev(dev); free_vqs: