From: Michael Buesch <mb@bu3sch.de>
To: linuxppc-dev@lists.ozlabs.org
Cc: Dave Boutcher <boutcher@us.ibm.com>,
Ryan Arnold <ryanarn@us.ibm.com>,
Colin Devilbiss <devilbis@us.ibm.com>
Subject: [PATCH] viotape: Fix memory and semaphore leak
Date: Sat, 18 Jul 2009 15:06:33 +0200 [thread overview]
Message-ID: <200907181506.33499.mb@bu3sch.de> (raw)
This patch fixes a memory and semaphore leak in the viotape driver's
char device write op. It leaks the DMA memory and the semaphore lock
in case the device was opened with O_NONBLOCK.
This patch is only compile tested, because I do not have the hardware.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
---
drivers/char/viotape.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
--- linux-2.6.orig/drivers/char/viotape.c
+++ linux-2.6/drivers/char/viotape.c
@@ -401,30 +401,31 @@ static ssize_t viotap_write(struct file
viopath_targetinst(viopath_hostLp),
(u64)(unsigned long)op, VIOVERSION << 16,
((u64)devi.devno << 48) | op->dmaaddr, count, 0, 0);
if (hvrc != HvLpEvent_Rc_Good) {
printk(VIOTAPE_KERN_WARN "hv error on op %d\n",
(int)hvrc);
ret = -EIO;
goto free_dma;
}
- if (noblock)
- return count;
-
- wait_for_completion(&op->com);
+ if (noblock) {
+ ret = count;
+ } else {
+ wait_for_completion(&op->com);
- if (op->rc)
- ret = tape_rc_to_errno(op->rc, "write", devi.devno);
- else {
- chg_state(devi.devno, VIOT_WRITING, file);
- ret = op->count;
+ if (op->rc)
+ ret = tape_rc_to_errno(op->rc, "write", devi.devno);
+ else {
+ chg_state(devi.devno, VIOT_WRITING, file);
+ ret = op->count;
+ }
}
free_dma:
dma_free_coherent(op->dev, count, op->buffer, op->dmaaddr);
up_sem:
up(&reqSem);
free_op:
free_op_struct(op);
return ret;
}
--
Greetings, Michael.
next reply other threads:[~2009-07-18 13:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-18 13:06 Michael Buesch [this message]
2009-08-13 5:00 ` [PATCH] viotape: Fix memory and semaphore leak Benjamin Herrenschmidt
2009-08-13 13:18 ` Michael Buesch
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200907181506.33499.mb@bu3sch.de \
--to=mb@bu3sch.de \
--cc=boutcher@us.ibm.com \
--cc=devilbis@us.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=ryanarn@us.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).