Re: [PATCH v3] pps: Fix a use-after-free
From: Greg Kroah-Hartman
Date: Tue Nov 05 2024 - 04:45:13 EST
On Mon, Nov 04, 2024 at 11:56:19PM -0800, Calvin Owens wrote:
> - dev_info(pps->dev, "removed\n");
> + dev_info(&pps->dev, "removed\n");
Nit, when drivers work properly, they are quiet, no need for these
dev_info() calls.
> static int pps_cdev_release(struct inode *inode, struct file *file)
> {
> - struct pps_device *pps = container_of(inode->i_cdev,
> - struct pps_device, cdev);
> - kobject_put(&pps->dev->kobj);
> + struct pps_device *pps = file->private_data;
> +
> + WARN_ON(pps->id != iminor(inode));
If this can happen, handle it and move on. Don't just reboot the
machine if it's something that could be triggered (remember about
panic-on-warn systems.)
thanks,
greg k-h