linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] pcmcia: fix error handling in cm4000_cs.c
@ 2010-04-18 19:07 Dan Carpenter
  2010-04-18 20:04 ` Harald Welte
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-04-18 19:07 UTC (permalink / raw)
  To: Harald Welte
  Cc: Dominik Brodowski, H Hartley Sweeten, Andrew Morton, Roel Kluin,
	Jiri Slaby, linux-kernel, kernel-janitors

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>

diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index c9bc896..90b199f 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -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);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch] pcmcia: fix error handling in cm4000_cs.c
  2010-04-18 19:07 [patch] pcmcia: fix error handling in cm4000_cs.c Dan Carpenter
@ 2010-04-18 20:04 ` Harald Welte
  0 siblings, 0 replies; 2+ messages in thread
From: Harald Welte @ 2010-04-18 20:04 UTC (permalink / raw)
  To: Dan Carpenter, Dominik Brodowski, H Hartley Sweeten,
	Andrew Morton, Roel Kluin, Jiri Slaby, linux-kernel,
	kernel-janitors

Hi Dan,

On Sun, Apr 18, 2010 at 10:07:33PM +0300, Dan Carpenter wrote:

> In the original code we used -ENODEV as the number of bytes to
> copy_to_user() and we didn't release the locks.

Thanks for pointing this out!
 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Acked-by: Harald Welte <laforge@gnumonks.org>

-- 
- Harald Welte <laforge@gnumonks.org>           http://laforge.gnumonks.org/
============================================================================
"Privacy in residential applications is a desirable marketing option."
                                                  (ETSI EN 300 175-7 Ch. A6)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-18 20:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-18 19:07 [patch] pcmcia: fix error handling in cm4000_cs.c Dan Carpenter
2010-04-18 20:04 ` Harald Welte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).