rpmsg fixes for v5.17-rc1
The cdev cleanup in the rpmsg_char driver was not performed properly, resulting in unpredicable behaviour when the parent remote processor is stopped with any of the cdevs open by a client. The two patches transitions the implementation to use cdev_device_add() and cdev_del_device(), to capture the relationship between the two objects, and relocates the incorrectly placed cdev_del(). -----BEGIN PGP SIGNATURE----- iQJPBAABCAA5FiEEBd4DzF816k8JZtUlCx85Pw2ZrcUFAmHxa4UbHGJqb3JuLmFu ZGVyc3NvbkBsaW5hcm8ub3JnAAoJEAsfOT8Nma3Fi7sQAMHdsaqZapq9MMLRtGJi YjpOvnH4ftOfr1+yfsKbbmH9ubUX4pdqgG7z+sRRzpmNjEwsKxe6rKXG30D+ZUX9 b8waVW5qC6A3VjDzDVdC+Mz2HhUkkeukxFzfwAuTOnpGHwtILkCid5A+jv1cJAz0 BDrszx+kIDrXC0KpI9V0mlPn2iqONYZHgjSRgQtw1xe2LtDL+5/iLvoP7hGq0qOx ujK9Ux+FOK2+H6G7xaNLK1GekVJBa2kZRcYYhHPpLrpV5Ul9IXpBGUYfiVFPp5WD ZDNQEImd96EQJs8rfQnAq9WhFtk95BSe/oGP2V/NB3O+RqD1IjtQxnFk99DFrXnQ DlgzSTD1iV356y8ZFPhlaCLAaPueFMXRRoKMhSaP28d3wNNOawDKwnXb7Amf7y2c Aeygibrh6UnOCROPWlvMrhImPuOiTyGBmD0TbNSGdYoXiZqpITmcVoW6NDyM0zST YB/PW091k6wXLmumARd5G6xK/+hALx6WFf50StxncXqax6aRy7HtaiqLMO95X+5w kD6GF4mBasqtYgRW9bWTndT/H2r09T9R5xksZDmWE9DAcsozz8HSBAXe8XqZiPED ZfqUlfHVBOYuMYb8P4bUYW3ZK9p5LIQeP1RbPojgWcf3/Rn6aLLg/mOUkbqRFSa7 XXj8jSmvMyGLbLFSvtcnU7z0 =KdZJ -----END PGP SIGNATURE----- Merge tag 'rpmsg-v5.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux Pull rpmsg fixes from Bjorn Andersson: "The cdev cleanup in the rpmsg_char driver was not performed properly, resulting in unpredicable behaviour when the parent remote processor is stopped with any of the cdevs open by a client. Two patches transitions the implementation to use cdev_device_add() and cdev_del_device(), to capture the relationship between the two objects, and relocates the incorrectly placed cdev_del()" * tag 'rpmsg-v5.17-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc/linux: rpmsg: char: Fix race between the release of rpmsg_eptdev and cdev rpmsg: char: Fix race between the release of rpmsg_ctrldev and cdev
This commit is contained in:
commit
626b2dda76
@ -93,7 +93,7 @@ static int rpmsg_eptdev_destroy(struct device *dev, void *data)
|
||||
/* wake up any blocked readers */
|
||||
wake_up_interruptible(&eptdev->readq);
|
||||
|
||||
device_del(&eptdev->dev);
|
||||
cdev_device_del(&eptdev->cdev, &eptdev->dev);
|
||||
put_device(&eptdev->dev);
|
||||
|
||||
return 0;
|
||||
@ -336,7 +336,6 @@ static void rpmsg_eptdev_release_device(struct device *dev)
|
||||
|
||||
ida_simple_remove(&rpmsg_ept_ida, dev->id);
|
||||
ida_simple_remove(&rpmsg_minor_ida, MINOR(eptdev->dev.devt));
|
||||
cdev_del(&eptdev->cdev);
|
||||
kfree(eptdev);
|
||||
}
|
||||
|
||||
@ -381,19 +380,13 @@ static int rpmsg_eptdev_create(struct rpmsg_ctrldev *ctrldev,
|
||||
dev->id = ret;
|
||||
dev_set_name(dev, "rpmsg%d", ret);
|
||||
|
||||
ret = cdev_add(&eptdev->cdev, dev->devt, 1);
|
||||
ret = cdev_device_add(&eptdev->cdev, &eptdev->dev);
|
||||
if (ret)
|
||||
goto free_ept_ida;
|
||||
|
||||
/* We can now rely on the release function for cleanup */
|
||||
dev->release = rpmsg_eptdev_release_device;
|
||||
|
||||
ret = device_add(dev);
|
||||
if (ret) {
|
||||
dev_err(dev, "device_add failed: %d\n", ret);
|
||||
put_device(dev);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
free_ept_ida:
|
||||
@ -462,7 +455,6 @@ static void rpmsg_ctrldev_release_device(struct device *dev)
|
||||
|
||||
ida_simple_remove(&rpmsg_ctrl_ida, dev->id);
|
||||
ida_simple_remove(&rpmsg_minor_ida, MINOR(dev->devt));
|
||||
cdev_del(&ctrldev->cdev);
|
||||
kfree(ctrldev);
|
||||
}
|
||||
|
||||
@ -497,19 +489,13 @@ static int rpmsg_chrdev_probe(struct rpmsg_device *rpdev)
|
||||
dev->id = ret;
|
||||
dev_set_name(&ctrldev->dev, "rpmsg_ctrl%d", ret);
|
||||
|
||||
ret = cdev_add(&ctrldev->cdev, dev->devt, 1);
|
||||
ret = cdev_device_add(&ctrldev->cdev, &ctrldev->dev);
|
||||
if (ret)
|
||||
goto free_ctrl_ida;
|
||||
|
||||
/* We can now rely on the release function for cleanup */
|
||||
dev->release = rpmsg_ctrldev_release_device;
|
||||
|
||||
ret = device_add(dev);
|
||||
if (ret) {
|
||||
dev_err(&rpdev->dev, "device_add failed: %d\n", ret);
|
||||
put_device(dev);
|
||||
}
|
||||
|
||||
dev_set_drvdata(&rpdev->dev, ctrldev);
|
||||
|
||||
return ret;
|
||||
@ -535,7 +521,7 @@ static void rpmsg_chrdev_remove(struct rpmsg_device *rpdev)
|
||||
if (ret)
|
||||
dev_warn(&rpdev->dev, "failed to nuke endpoints: %d\n", ret);
|
||||
|
||||
device_del(&ctrldev->dev);
|
||||
cdev_device_del(&ctrldev->cdev, &ctrldev->dev);
|
||||
put_device(&ctrldev->dev);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user