Commit f997ea3b authored by Xie Yongji's avatar Xie Yongji Committed by Dominique Martinet
Browse files

9p/trans_virtio: Remove sysfs file on probe failure

This ensures we don't leak the sysfs file if we failed to
allocate chan->vc_wq during probe.

Link: http://lkml.kernel.org/r/20210517083557.172-1-xieyongji@bytedance.com


Fixes: 86c84373 ("net/9p: Add sysfs mount_tag file for virtio 9P device")
Signed-off-by: default avatarXie Yongji <xieyongji@bytedance.com>
Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
parent ff117646
Loading
Loading
Loading
Loading
+3 −1
Original line number Original line Diff line number Diff line
@@ -610,7 +610,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
	chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
	chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
	if (!chan->vc_wq) {
	if (!chan->vc_wq) {
		err = -ENOMEM;
		err = -ENOMEM;
		goto out_free_tag;
		goto out_remove_file;
	}
	}
	init_waitqueue_head(chan->vc_wq);
	init_waitqueue_head(chan->vc_wq);
	chan->ring_bufs_avail = 1;
	chan->ring_bufs_avail = 1;
@@ -628,6 +628,8 @@ static int p9_virtio_probe(struct virtio_device *vdev)


	return 0;
	return 0;


out_remove_file:
	sysfs_remove_file(&vdev->dev.kobj, &dev_attr_mount_tag.attr);
out_free_tag:
out_free_tag:
	kfree(tag);
	kfree(tag);
out_free_vq:
out_free_vq: