Skip to content

Commit c613f77

Browse files
YuKuai-huaweigregkh
authored andcommitted
char: pcmcia: error out if 'num_bytes_read' is greater than 4 in set_protocol()
[ Upstream commit 3718855 ] Theoretically, it will cause index out of bounds error if 'num_bytes_read' is greater than 4. As we expect it(and was tested) never to be greater than 4, error out if it happens. Fixes: c1986ee ("[PATCH] New Omnikey Cardman 4000 driver") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Link: https://lore.kernel.org/r/20210521120617.138396-1-yukuai3@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 1a4bc25 commit c613f77

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎drivers/char/pcmcia/cm4000_cs.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
544544
io_read_num_rec_bytes(iobase, &num_bytes_read);
545545
if (num_bytes_read >= 4) {
546546
DEBUGP(2, dev, "NumRecBytes = %i\n", num_bytes_read);
547+
if (num_bytes_read > 4) {
548+
rc = -EIO;
549+
goto exit_setprotocol;
550+
}
547551
break;
548552
}
549553
usleep_range(10000, 11000);

0 commit comments

Comments
 (0)