On Fri, Feb 15, 2019 at 05:17:27PM +0800, Hsin-Yi Wang wrote:
> Ok, I can add a check in another patch. Should we return NULL pointer
> if msg->len is 0 or print out some warnings? Thanks.

No warning, msg->len == 0 is a valid setting. But interesting question:
I was about to say NULL, but your driver would assume ENOMEM there and
discard the message which is also not correct since msg->len == 0 is a
valid setting. So, should we just return msg->buf then? Will this work
with your driver? Can it handle zero-length transfers?

> On Fri, Feb 15, 2019 at 5:10 PM Wolfram Sang <w...@the-dreams.de> wrote:
> >
> > On Fri, Feb 15, 2019 at 05:02:02PM +0800, Hsin-Yi Wang wrote:
> > > i2c_get_dma_safe_msg_buf() allocates space based on msg->len. If 
> > > threshold is
> > > 0 and msg->len is also 0, function makes zero-length allocation, which 
> > > returns
> > > a special ZERO_SIZE_PTR instead of a NULL pointer, and this will cause 
> > > later
> > > code to fail. Modify the threshold to > 0 so the function returns NULL 
> > > pointer.
> > >
> > > Fixes: fc66b39fe36a ("i2c: mediatek: Use DMA safe buffers for i2c 
> > > transactions")
> > > Signed-off-by: Hsin-Yi Wang <hsi...@chromium.org>
> >
> > Right. But we need to fix i2c_get_dma_safe_msg_buf(), so it will be
> > handled for all callers. Do you want to add a check if msg->len is 0 or
> > shall I? Both fine for me.
> >

Attachment: signature.asc
Description: PGP signature

Reply via email to