vch will be free in virtio_rpmsg_release_device() when rpmsg_ns_register_device() fails. There is no need to call kfree() again. Fix this by changing error path from free_vch to free_ctrldev.
Showing the changes to drivers/rpmsg (1 of 1 file). Show all
Unified · Split
| @@ -973,7 +973,8 @@ static int rpmsg_probe(struct virtio_device *vdev) · 972 unmodified lines | ||
| 973 | 973 | |
| 974 | 974 | err = rpmsg_ns_register_device(rpdev_ns); |
| 975 | 975 | if (err) |
| 976 | − goto free_vch; | |
| 976 | + /* vch will be free in virtio_rpmsg_release_device() */ | |
| 977 | + goto free_ctrldev; | |
| 977 | 978 | } |
| 978 | 979 | |
| 979 | 980 | /* |
| @@ -997,8 +998,6 @@ static int rpmsg_probe(struct virtio_device *vdev) · 17 unmodified lines | ||
| 997 | 998 | |
| 998 | 999 | return 0; |
| 999 | 1000 | |
| 1000 | −free_vch: | |
| 1001 | − kfree(vch); | |
| 1002 | 1001 | free_ctrldev: |
| 1003 | 1002 | rpmsg_virtio_del_ctrl_dev(rpdev_ctrl); |
| 1004 | 1003 | free_coherent: |