This patch prevents ppdev from oopsing when the PPGETMODES ioctl is
used before a PPCLAIM.
* drivers/char/ppdev.c: Fix an oops in PPGETMODES handling.
{
unsigned int modes;
- modes = pp->pdev->port->modes;
- if (copy_to_user ((unsigned int *)arg, &modes, sizeof (port->modes))) {
+ port = parport_find_number (minor);
+ if (!port)
+ return -ENODEV;
+
+ modes = port->modes;
+ if (copy_to_user ((unsigned int *)arg, &modes, sizeof (modes))) {
return -EFAULT;
}
return 0;