From: Malcolm Priestley <tvboxspy@gmail.com>
To: linux-media@vger.kernel.org
Subject: [PATCH ] dvb-usb provide exit for any structure inside priv.
Date: Mon, 16 May 2011 23:07:17 +0100 [thread overview]
Message-ID: <1305583637.2481.3.camel@localhost> (raw)
Currently priv is freed from memory by dvb-usb on any error or exit.
If any buffer has been allocated in the priv structure,
freeing it is tricky. While freeing it on device disconnect
is fairly easy, on error it is almost impossible because it
has been removed from memory by dvb-usb.
This patch provides an exit from the priv.
Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
---
drivers/media/dvb/dvb-usb/dvb-usb-init.c | 2 ++
drivers/media/dvb/dvb-usb/dvb-usb.h | 1 +
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb-init.c b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
index 2e3ea0f..217b948 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb-init.c
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-init.c
@@ -118,6 +118,8 @@ static int dvb_usb_exit(struct dvb_usb_device *d)
dvb_usb_i2c_exit(d);
deb_info("state should be zero now: %x\n", d->state);
d->state = DVB_USB_STATE_INIT;
+ if (d->props.priv_exit)
+ d->props.priv_exit(d);
kfree(d->priv);
kfree(d);
return 0;
diff --git a/drivers/media/dvb/dvb-usb/dvb-usb.h b/drivers/media/dvb/dvb-usb/dvb-usb.h
index 76a8096..044c906 100644
--- a/drivers/media/dvb/dvb-usb/dvb-usb.h
+++ b/drivers/media/dvb/dvb-usb/dvb-usb.h
@@ -263,6 +263,7 @@ struct dvb_usb_device_properties {
int no_reconnect;
int size_of_priv;
+ int (*priv_exit) (struct dvb_usb_device *);
int num_adapters;
struct dvb_usb_adapter_properties adapter[MAX_NO_OF_ADAPTER_PER_DEVICE];
--
1.7.4.1
next reply other threads:[~2011-05-16 22:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-16 22:07 Malcolm Priestley [this message]
2011-05-21 13:14 ` [PATCH ] dvb-usb provide exit for any structure inside priv Mauro Carvalho Chehab
2011-05-22 2:29 ` Malcolm Priestley
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=1305583637.2481.3.camel@localhost \
--to=tvboxspy@gmail.com \
--cc=linux-media@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox