Skip to content

Commit

Permalink
[media] v4l: make sure drivers supply a zeroed struct v4l2_subdev
Browse files Browse the repository at this point in the history
Some v4l drivers currently don't initialize their struct v4l2_subdev
with zeros, and this is a problem since some of the v4l2 code expects
this. One example is the addition of internal_ops in commit 45f6f84,
after that we are at risk of random oopses with these drivers when code
in v4l2_device_register_subdev tries to dereference sd->internal_ops->*,
as can be shown by the report at http://bugs.launchpad.net/bugs/745213
and analysis of its crash at https://lkml.org/lkml/2011/4/1/168

Use kzalloc within problematic drivers to ensure we have a zeroed struct
v4l2_subdev.

BugLink: http://bugs.launchpad.net/bugs/745213
Cc: <stable@kernel.org>
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Herton Ronaldo Krzesinski authored and Mauro Carvalho Chehab committed Apr 29, 2011
1 parent 2b5cb54 commit 80845a3
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion drivers/media/radio/saa7706h.c
Expand Up @@ -376,7 +376,7 @@ static int __devinit saa7706h_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%02x (%s)\n",
client->addr << 1, client->adapter->name);

state = kmalloc(sizeof(struct saa7706h_state), GFP_KERNEL);
state = kzalloc(sizeof(struct saa7706h_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
sd = &state->sd;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/radio/tef6862.c
Expand Up @@ -176,7 +176,7 @@ static int __devinit tef6862_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%02x (%s)\n",
client->addr << 1, client->adapter->name);

state = kmalloc(sizeof(struct tef6862_state), GFP_KERNEL);
state = kzalloc(sizeof(struct tef6862_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
state->freq = TEF6862_LO_FREQ;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/m52790.c
Expand Up @@ -174,7 +174,7 @@ static int m52790_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);

state = kmalloc(sizeof(struct m52790_state), GFP_KERNEL);
state = kzalloc(sizeof(struct m52790_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/tda9840.c
Expand Up @@ -171,7 +171,7 @@ static int tda9840_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);

sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
if (sd == NULL)
return -ENOMEM;
v4l2_i2c_subdev_init(sd, client, &tda9840_ops);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/tea6415c.c
Expand Up @@ -152,7 +152,7 @@ static int tea6415c_probe(struct i2c_client *client,

v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);
sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
if (sd == NULL)
return -ENOMEM;
v4l2_i2c_subdev_init(sd, client, &tea6415c_ops);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/tea6420.c
Expand Up @@ -125,7 +125,7 @@ static int tea6420_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);

sd = kmalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
sd = kzalloc(sizeof(struct v4l2_subdev), GFP_KERNEL);
if (sd == NULL)
return -ENOMEM;
v4l2_i2c_subdev_init(sd, client, &tea6420_ops);
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/upd64031a.c
Expand Up @@ -230,7 +230,7 @@ static int upd64031a_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);

state = kmalloc(sizeof(struct upd64031a_state), GFP_KERNEL);
state = kzalloc(sizeof(struct upd64031a_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
sd = &state->sd;
Expand Down
2 changes: 1 addition & 1 deletion drivers/media/video/upd64083.c
Expand Up @@ -202,7 +202,7 @@ static int upd64083_probe(struct i2c_client *client,
v4l_info(client, "chip found @ 0x%x (%s)\n",
client->addr << 1, client->adapter->name);

state = kmalloc(sizeof(struct upd64083_state), GFP_KERNEL);
state = kzalloc(sizeof(struct upd64083_state), GFP_KERNEL);
if (state == NULL)
return -ENOMEM;
sd = &state->sd;
Expand Down

0 comments on commit 80845a3

Please sign in to comment.