Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 07a71415 authored by Dan Carpenter's avatar Dan Carpenter Committed by Dominik Brodowski
Browse files

pcmcia: fix error handling in cm4000_cs.c



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: default avatarDan Carpenter <error27@gmail.com>
Acked-by: default avatarHarald Welte <laforge@gnumonks.org>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 42d284b9
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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);