All of lore.kernel.org
 help / color / mirror / Atom feed
From: Devendra Naga <devendra.aaru@gmail.com>
To: Ian Abbott <abbotti@mev.co.uk>,
	Mori Hess <fmhess@users.sourceforge.net>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Cc: Devendra Naga <devendra.aaru@gmail.com>
Subject: [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices
Date: Sun,  1 Jul 2012 21:50:24 +0530	[thread overview]
Message-ID: <1341159624-23968-1-git-send-email-devendra.aaru@gmail.com> (raw)

as comedi_alloc_subdevices may fail, we leak out the memory allocated by alloc_private,
and also the I/O regions we requested.

free out the private data pointer of the driver, and release the I/O regions

Signed-off-by: Devendra Naga <devendra.aaru@gmail.com>
---
 drivers/staging/comedi/drivers/fl512.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/fl512.c b/drivers/staging/comedi/drivers/fl512.c
index 52e6d14..1c372d1 100644
--- a/drivers/staging/comedi/drivers/fl512.c
+++ b/drivers/staging/comedi/drivers/fl512.c
@@ -135,8 +135,11 @@ static int fl512_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 #endif
 
 	ret = comedi_alloc_subdevices(dev, 2);
-	if (ret)
+	if (ret) {
+		kfree(dev->private);
+		release_region(iobase, FL512_SIZE);
 		return ret;
+	}
 
 	/*
 	 * this if the definitions of the supdevices, 2 have been defined
-- 
1.7.9.5


             reply	other threads:[~2012-07-01 16:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-01 16:20 Devendra Naga [this message]
2012-07-02  8:45 ` [PATCH V3 2/2] staging/comedi/drivers: free allocated priv and release resources if comedi_alloc_subdevices Ian Abbott
2012-07-02  8:51   ` devendra.aaru
     [not found]     ` <4FF16773.3030202@mev.co.uk>
2012-07-02  9:22       ` devendra.aaru

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=1341159624-23968-1-git-send-email-devendra.aaru@gmail.com \
    --to=devendra.aaru@gmail.com \
    --cc=abbotti@mev.co.uk \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=fmhess@users.sourceforge.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=hsweeten@visionengravers.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.