Skip to content

Commit e464b38

Browse files
YongjiXiegregkh
authored andcommitted
9p/trans_virtio: Remove sysfs file on probe failure
commit f997ea3 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: 86c8437 ("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>
1 parent 375e779 commit e464b38

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/9p/trans_virtio.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ static int p9_virtio_probe(struct virtio_device *vdev)
605605
chan->vc_wq = kmalloc(sizeof(wait_queue_head_t), GFP_KERNEL);
606606
if (!chan->vc_wq) {
607607
err = -ENOMEM;
608-
goto out_free_tag;
608+
goto out_remove_file;
609609
}
610610
init_waitqueue_head(chan->vc_wq);
611611
chan->ring_bufs_avail = 1;
@@ -623,6 +623,8 @@ static int p9_virtio_probe(struct virtio_device *vdev)
623623

624624
return 0;
625625

626+
out_remove_file:
627+
sysfs_remove_file(&vdev->dev.kobj, &dev_attr_mount_tag.attr);
626628
out_free_tag:
627629
kfree(tag);
628630
out_free_vq:

0 commit comments

Comments
 (0)