]> git.hungrycats.org Git - linux/commitdiff
[PATCH] 2.5.3-pre6: getmodes
authorTim Waugh <twaugh@redhat.com>
Tue, 5 Feb 2002 08:36:47 +0000 (00:36 -0800)
committerLinus Torvalds <torvalds@athlon.transmeta.com>
Tue, 5 Feb 2002 08:36:47 +0000 (00:36 -0800)
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.

drivers/char/ppdev.c

index bdebe0aee56387838083aa3be8e483e66d025795..dcc2d559ad1cb5cc55b0d4fe3d70c6bef6aecf7b 100644 (file)
@@ -429,8 +429,12 @@ static int pp_ioctl(struct inode *inode, struct file *file,
            {
                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;