Re: [PATCH] char: pcmcia: remove set but not used variable 'tmp'

From: Arnd Bergmann
Date: Sat May 15 2021 - 05:06:14 EST


On Sat, May 15, 2021 at 9:15 AM yukuai (C) <yukuai3@xxxxxxxxxx> wrote:
> On 2021/05/14 14:28, Arnd Bergmann wrote:
>
> I'm not familar with the logical here, however, if io_read_num_rec_bytes
> may get 'num_bytes_read' greater than 4, this loop will cause index out
> of boundary. It make sense to me to add a range check. Futhermore, since
> 'num_bytes_read' is ensure to >= 4,I think we can change the loop to:
>
> for (i = 0; i < 4; ++i) {
> xoutb(i, REG_BUF_ADDR(iobase));
> pts_reply[i] = inb(REG_BUF_DATA(iobase));
> }

Obviously it still has to use the num_bytes_read value to determine
how many bytes were actually received, but there should be an
added cap to tell the compiler that this is never more than 4.

Arnd