On Sun, Dec 16, 2018 at 9:15 AM Andrew Lunn <[email protected]> wrote:
>
> On Sun, Dec 16, 2018 at 08:57:40AM +0100, Sergio Paracuellos wrote:
> > +static int ksz_i2c_read_reg(struct i2c_client *client, u32 reg, u8 *val,
> > + unsigned int len)
> > +{
> > + struct i2c_adapter *adapter = client->adapter;
> > + struct i2c_msg msg[2];
> > + u8 txd[2];
>
Hi Andrew,
> Hi Sergio
>
> I'm not sure that having the TX buffer on the stack is safe. If the
> i2c bus master is using DMA, you then DMA from the stack, which some
> architectures memory models do no allow. You have to use memory which
> comes from an alloc function.
>
> > + int ret;
> > +
> > + txd[0] = (u8)(reg >> 8);
> > + txd[1] = (u8)reg;
> > +
> > + msg[0].addr = client->addr;
> > + msg[0].flags = 0;
> > + msg[0].len = 2;
> > + msg[0].buf = txd;
> > +
> > + msg[1].addr = client->addr;
> > + msg[1].flags = I2C_M_RD;
> > + msg[1].len = len;
> > + msg[1].buf = val;
>
> You potentially have the same issue with val.
>
I'll change these two to to get memory from kernel allocators instead
of using the stack. Thanks for let me know this.
> Andrew
Best regards,
Sergio Paracuellos
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel