Skip to content

Commit

Permalink
pcmcia: fix error handling in cm4000_cs.c
Browse files Browse the repository at this point in the history
In the original code we used -ENODEV as the number of bytes to
copy_to_user() and we didn't release the locks.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
  • Loading branch information
Dan Carpenter authored and Dominik Brodowski committed Apr 19, 2010
1 parent 42d284b commit 07a7141
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/char/pcmcia/cm4000_cs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,14 +1026,16 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,

xoutb(0, REG_FLAGS1(iobase)); /* clear detectCMM */
/* last check before exit */
if (!io_detect_cm4000(iobase, dev))
count = -ENODEV;
if (!io_detect_cm4000(iobase, dev)) {
rc = -ENODEV;
goto release_io;
}

if (test_bit(IS_INVREV, &dev->flags) && count > 0)
str_invert_revert(dev->rbuf, count);

if (copy_to_user(buf, dev->rbuf, count))
return -EFAULT;
rc = -EFAULT;

release_io:
clear_bit(LOCK_IO, &dev->flags);
Expand Down

0 comments on commit 07a7141

Please sign in to comment.