rpmsg: qcom: glink: replace strncpy() with strscpy_pad()
[platform/kernel/linux-rpi.git] / drivers / rpmsg / virtio_rpmsg_bus.c
index 8e49a3b..b03e740 100644 (file)
@@ -842,7 +842,7 @@ static struct rpmsg_device *rpmsg_virtio_add_ctrl_dev(struct virtio_device *vdev
 
        err = rpmsg_chrdev_register_device(rpdev_ctrl);
        if (err) {
-               kfree(vch);
+               /* vch will be free in virtio_rpmsg_release_device() */
                return ERR_PTR(err);
        }
 
@@ -853,7 +853,7 @@ static void rpmsg_virtio_del_ctrl_dev(struct rpmsg_device *rpdev_ctrl)
 {
        if (!rpdev_ctrl)
                return;
-       kfree(to_virtio_rpmsg_channel(rpdev_ctrl));
+       device_unregister(&rpdev_ctrl->dev);
 }
 
 static int rpmsg_probe(struct virtio_device *vdev)
@@ -964,7 +964,8 @@ static int rpmsg_probe(struct virtio_device *vdev)
 
                err = rpmsg_ns_register_device(rpdev_ns);
                if (err)
-                       goto free_vch;
+                       /* vch will be free in virtio_rpmsg_release_device() */
+                       goto free_ctrldev;
        }
 
        /*
@@ -988,8 +989,6 @@ static int rpmsg_probe(struct virtio_device *vdev)
 
        return 0;
 
-free_vch:
-       kfree(vch);
 free_ctrldev:
        rpmsg_virtio_del_ctrl_dev(rpdev_ctrl);
 free_coherent: