public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi/virio_scsi.c: do not call virtscsi_remove_vqs() in virtscsi_init() to avoid crash bug
@ 2018-08-23  2:24 piaojun
  2018-10-12 14:55 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: piaojun @ 2018-08-23  2:24 UTC (permalink / raw)
  To: stefanha, pbonzini
  Cc: linux-kernel, rusty, kvm, penberg, mst, stefanha, michaelc

If some error happened before find_vqs, error branch will goto
virtscsi_remove_vqs to free vqs. Actually the vqs have not been allocated
successfully, so this will cause wild-pointer-free problem. So
virtscsi_remove_vqs could be deleted as no error will happen after
find_vqs.

Signed-off-by: Jun Piao <piaojun@huawei.com>
---
 drivers/scsi/virtio_scsi.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 1c72db9..da0fd74 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -833,8 +833,6 @@ static int virtscsi_init(struct virtio_device *vdev,
 	kfree(names);
 	kfree(callbacks);
 	kfree(vqs);
-	if (err)
-		virtscsi_remove_vqs(vdev);
 	return err;
 }

-- 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] scsi/virio_scsi.c: do not call virtscsi_remove_vqs() in virtscsi_init() to avoid crash bug
  2018-08-23  2:24 [PATCH] scsi/virio_scsi.c: do not call virtscsi_remove_vqs() in virtscsi_init() to avoid crash bug piaojun
@ 2018-10-12 14:55 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2018-10-12 14:55 UTC (permalink / raw)
  To: piaojun; +Cc: pbonzini, linux-kernel, rusty, kvm, penberg, mst, michaelc

[-- Attachment #1: Type: text/plain, Size: 1114 bytes --]

On Thu, Aug 23, 2018 at 10:24:58AM +0800, piaojun wrote:
> If some error happened before find_vqs, error branch will goto
> virtscsi_remove_vqs to free vqs. Actually the vqs have not been allocated
> successfully, so this will cause wild-pointer-free problem. So
> virtscsi_remove_vqs could be deleted as no error will happen after
> find_vqs.
> 
> Signed-off-by: Jun Piao <piaojun@huawei.com>
> ---
>  drivers/scsi/virtio_scsi.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 1c72db9..da0fd74 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -833,8 +833,6 @@ static int virtscsi_init(struct virtio_device *vdev,
>  	kfree(names);
>  	kfree(callbacks);
>  	kfree(vqs);
> -	if (err)
> -		virtscsi_remove_vqs(vdev);

Can you provide more details about the problem?

drivers/virtio/virtio_pci_common.c:vp_del_vqs() looks fine to me, it
iterates over vdev->vqs.  The vdev->vqs list has been initialized in
drivers/virtio/virtio.c:register_virtio_device() and it's empty.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-12 14:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23  2:24 [PATCH] scsi/virio_scsi.c: do not call virtscsi_remove_vqs() in virtscsi_init() to avoid crash bug piaojun
2018-10-12 14:55 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox