Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: [patch] kernel i2c - alps_tdmb7
On Tuesday 22 June 2004 13:04, Kenneth Aafløy wrote:
> Hi!
>
> Here is another one, it's pretty straight forward, and should work ok.
> Would still be nice if someone with this frontend could test it though.
>
> I'm wondering about this case though, it's highly unlikly to happen, but if
> the i2c_attach_client succeds and dvb_register_frontend_new fails, I belive
> that state and client will be double free'd. Something like this is used in
> most of the converted frontends (exceptions: stv0299/ves1x93, which looks
> like they'll leak state on detach_client).
Oh no :)
Sorry, jumped to conclusions, and didn't realize until after send. stv/ves
will still leak on detach_client though.
Attached two patches, which fixes this and copy/paste bugs ves1x93.
Kenneth
Index: linux/drivers/media/dvb/frontends/stv0299.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/stv0299.c,v
retrieving revision 1.45
diff -u -r1.45 stv0299.c
--- linux/drivers/media/dvb/frontends/stv0299.c 21 Jun 2004 14:06:30 -0000 1.45
+++ linux/drivers/media/dvb/frontends/stv0299.c 22 Jun 2004 11:18:13 -0000
@@ -1388,21 +1388,23 @@
static int detach_client(struct i2c_client *client)
{
+ struct stv0299_state *state = i2c_get_clientdata(client);
+
i2c_detach_client(client);
kfree(client);
+ kfree(state);
return 0;
}
static int command (struct i2c_client *client, unsigned int cmd, void *arg)
{
- struct stv0299_data *data = (struct stv0299_data*)i2c_get_clientdata(client);
-
dprintk ("%s\n", __FUNCTION__);
switch (cmd) {
case FE_REGISTER: {
struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg;
- return dvb_register_frontend_new (uni0299_ioctl, dvb_adapter, (void*) data, &uni0299_info);
+ return dvb_register_frontend_new (uni0299_ioctl, dvb_adapter,
+ i2c_get_clientdata(client), &uni0299_info);
}
case FE_UNREGISTER: {
struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg;
Index: linux/drivers/media/dvb/frontends/ves1x93.c
===================================================================
RCS file: /cvs/linuxtv/dvb-kernel/linux/drivers/media/dvb/frontends/ves1x93.c,v
retrieving revision 1.9
diff -u -r1.9 ves1x93.c
--- linux/drivers/media/dvb/frontends/ves1x93.c 3 May 2004 16:29:28 -0000 1.9
+++ linux/drivers/media/dvb/frontends/ves1x93.c 22 Jun 2004 11:17:46 -0000
@@ -637,21 +637,23 @@
static int detach_client(struct i2c_client *client)
{
+ struct ves1x93_state *state = i2c_get_clientdata(client);
+
i2c_detach_client(client);
kfree(client);
+ kfree(state);
return 0;
}
static int command (struct i2c_client *client, unsigned int cmd, void *arg)
{
- struct stv0299_data *data = (struct stv0299_data*)i2c_get_clientdata(client);
-
dprintk ("%s\n", __FUNCTION__);
switch (cmd) {
case FE_REGISTER: {
struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg;
- return dvb_register_frontend_new (ves1x93_ioctl, dvb_adapter, (void*) data, &ves1x93_info);
+ return dvb_register_frontend_new (ves1x93_ioctl, dvb_adapter,
+ i2c_get_clientdata(client), &ves1x93_info);
}
case FE_UNREGISTER: {
struct dvb_adapter *dvb_adapter = (struct dvb_adapter*)arg;
@@ -675,7 +677,7 @@
};
static struct i2c_client client_template = {
- I2C_DEVNAME("stv0299"),
+ I2C_DEVNAME("ves1x93"),
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
Home |
Main Index |
Thread Index