Messages in this thread |  | | From | Arnd Bergmann <> | Date | Sat, 15 May 2021 11:05:06 +0200 | Subject | Re: [PATCH] char: pcmcia: remove set but not used variable 'tmp' |
| |
On Sat, May 15, 2021 at 9:15 AM yukuai (C) <yukuai3@huawei.com> 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
|  |