summaryrefslogtreecommitdiff
path: root/net/9p
diff options
context:
space:
mode:
authorXie Yongji <xieyongji@bytedance.com>2021-05-17 11:35:57 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-26 15:08:57 +0300
commite464b3876b022c0c4e0eb21518c491c6eb38130c (patch)
treef0aa737e904ca2d7217816e441cddb42f7c71051 /net/9p
parent375e779ec32a87edeb6bb26582c1c9a1f59876f9 (diff)
downloadlinux-e464b3876b022c0c4e0eb21518c491c6eb38130c.tar.xz
9p/trans_virtio: Remove sysfs file on probe failure
commit f997ea3b7afc108eb9761f321b57de2d089c7c48 upstream. 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: 86c8437383ac ("net/9p: Add sysfs mount_tag file for virtio 9P device") Signed-off-by: Xie Yongji <xieyongji@bytedance.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/9p')
-rw-r--r--net/9p/trans_virtio.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index a3cd90a74012..f582351d84ec 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -605,7 +605,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
if (!chan->vc_wq) {
err = -ENOMEM;
- goto out_free_tag;
+ goto out_remove_file;
}
init_waitqueue_head(chan->vc_wq);
chan->ring_bufs_avail = 1;
@@ -623,6 +623,8 @@ static int p9_virtio_probe(struct virtio_device *vdev)
return 0;
+out_remove_file:
+ sysfs_remove_file(&vdev->dev.kobj, &dev_attr_mount_tag.attr);
out_free_tag:
kfree(tag);
out_free_vq: