public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH ] dvb-usb provide exit for any structure inside priv.
@ 2011-05-16 22:07 Malcolm Priestley
  2011-05-21 13:14 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 3+ messages in thread
From: Malcolm Priestley @ 2011-05-16 22:07 UTC (permalink / raw)
  To: linux-media

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


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

end of thread, other threads:[~2011-05-22  2:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-16 22:07 [PATCH ] dvb-usb provide exit for any structure inside priv Malcolm Priestley
2011-05-21 13:14 ` Mauro Carvalho Chehab
2011-05-22  2:29   ` Malcolm Priestley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox