Re: [PATCH v2 10/15] auxdisplay: linedisp: Provide a small buffer in the struct linedisp

From: Andy Shevchenko
Date: Thu Feb 15 2024 - 07:23:07 EST


On Thu, Feb 15, 2024 at 11:40:44AM +0100, Geert Uytterhoeven wrote:
> On Mon, Feb 12, 2024 at 6:04 PM Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

..

> > + linedisp->buf = buf ? buf : linedisp->curr;
> > + linedisp->num_chars = buf ? num_chars : min(num_chars, LINEDISP_DEFAULT_BUF_SZ);
>
> I think it would be safer to return an error if buf == NULL and
> num_chars < LINEDISP_DEFAULT_BUF_SZ.

I think you meant >= ?

> Else a careless driver that doesn't check linedisp->num_chars might
> overflow the buffer.

Okay, check has been added.

--
With Best Regards,
Andy Shevchenko