Skip to contentSkip to conversation

V4L/DVB (12730): Add conexant cx25821 driver

DISCUSSION Dan Carpenter 3 participants 4 messages Jun 16, 2012 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

Hello Palash Bandyopadhyay,

The patch 02b20b0b4cde: "V4L/DVB (12730): Add conexant cx25821 driver" from Sep 15, 2009, leads to the following warning:
drivers/media/video/cx25821/cx25821-i2c.c:310 cx25821_i2c_register()

	 error: memcpy() '&cx25821_i2c_algo_template' too small (24 vs 64)

306 dprintk(1, "%s(bus = %d)\n", __func__, bus->nr);
307
308 memcpy(&bus->i2c_adap, &cx25821_i2c_adap_template,
309 sizeof(bus->i2c_adap));

Quoted 1 line

310 memcpy(&bus->i2c_algo, &cx25821_i2c_algo_template,

311 sizeof(bus->i2c_algo));
312 memcpy(&bus->i2c_client, &cx25821_i2c_client_template,
313 sizeof(bus->i2c_client));
314

The problem is that "bus->i2c_algo" is a i2c_algo_bit_data struct and cx25821_i2c_algo_template is a i2c_algorithm struct. They are different sizes and the function pointers don't line up at all. I don't see how this can work at all.

regards,
dan carpenter

#1 lore raw

Hm... There are several more places which have this same problem. I'm not sure what's going on here.

drivers/media/video/saa7164/saa7164-i2c.c:112 saa7164_i2c_register() error: memcpy() '&saa7164_i2c_algo_template' too small (24 vs 64) drivers/media/video/cx23885/cx23885-i2c.c:321 cx23885_i2c_register() error: memcpy() '&cx23885_i2c_algo_template' too small (24 vs 64) drivers/media/video/cx231xx/cx231xx-i2c.c:503 cx231xx_i2c_register() error: memcpy() '&cx231xx_algo' too small (24 vs 64)

regards,
dan carpenter

#2 lore raw

Hi everyone,

Quoted 5 lines · Dan Carpenter

Hm...  There are several more places which have this same problem. I'm not sure what's going on here.

drivers/media/video/saa7164/saa7164-i2c.c:112 saa7164_i2c_register() error: memcpy() '&saa7164_i2c_algo_template' too small (24 vs 64)

I was just looking at that lines in saa7164_i2c_register:

112 memcpy(&bus->i2c_algo, &saa7164_i2c_algo_template,
113 sizeof(bus->i2c_algo));

They seem like pointless to me. The real algo is set here:

93 static struct i2c_adapter saa7164_i2c_adap_template = {

 94         .name              = "saa7164",
 95         .owner             = THIS_MODULE,
 96         .algo              = &saa7164_i2c_algo_template,

97 };

This would also mean that this fields are also pointless:

254         struct i2c_algo_bit_data        i2c_algo;
255         struct i2c_client               i2c_client;

IMO, the issue pointed out by Dan would never appeared if instead of using memcpy to fill the structures, it would just get assigned; it's type safe, right?

Please correct me if I'm wrong,
Ezequiel.

#3 lore raw
In reply to Dan Carpenter

Thanks Dan.

Let me take a look and get back to you.

Rgds,
Palash
________________________________________
From: Dan Carpenter [[email protected]]
Sent: Saturday, June 16, 2012 6:16 AM
To: Palash Bandyopadhyay; [email protected]
Cc: [email protected]
Subject: re: V4L/DVB (12730): Add conexant cx25821 driver

Hello Palash Bandyopadhyay,

The patch 02b20b0b4cde: "V4L/DVB (12730): Add conexant cx25821 driver" from Sep 15, 2009, leads to the following warning:
drivers/media/video/cx25821/cx25821-i2c.c:310 cx25821_i2c_register()

         error: memcpy() '&cx25821_i2c_algo_template' too small (24 vs 64)

306 dprintk(1, "%s(bus = %d)\n", __func__, bus->nr);
307
308 memcpy(&bus->i2c_adap, &cx25821_i2c_adap_template,
309 sizeof(bus->i2c_adap));

Quoted 1 line

310 memcpy(&bus->i2c_algo, &cx25821_i2c_algo_template,

311 sizeof(bus->i2c_algo));
312 memcpy(&bus->i2c_client, &cx25821_i2c_client_template,
313 sizeof(bus->i2c_client));
314

The problem is that "bus->i2c_algo" is a i2c_algo_bit_data struct and cx25821_i2c_algo_template is a i2c_algorithm struct. They are different sizes and the function pointers don't line up at all. I don't see how this can work at all.

regards,
dan carpenter
Conexant E-mail Firewall (Conexant.Com) made the following annotations
---------------------------------------------------------------------
********************** Legal Disclaimer ****************************

"This email may contain confidential and privileged material for the sole use of the intended recipient. Any unauthorized review, use or distribution by others is strictly prohibited. If you have received the message in error, please advise the sender by reply email and delete the message. Thank you."

**********************************************************************

---------------------------------------------------------------------