summaryrefslogtreecommitdiff
path: root/drivers/char/pcmcia
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2021-05-21 20:06:17 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-27 14:45:54 +0200
commit37188559c610f1b7eec83c8e448936c361c578de (patch)
treea4266dbcf23c222f740e0f1d4719a2434858413e /drivers/char/pcmcia
parent7af5662826f7b1639490c999e6bac14ea6a79a7c (diff)
char: pcmcia: error out if 'num_bytes_read' is greater than 4 in set_protocol()
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: c1986ee9bea3 ("[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>
Diffstat (limited to 'drivers/char/pcmcia')
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 9ec25735425d..8f1bce0b4fe5 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -544,6 +544,10 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq)
io_read_num_rec_bytes(iobase, &num_bytes_read);
if (num_bytes_read >= 4) {
DEBUGP(2, dev, "NumRecBytes = %i\n", num_bytes_read);
+ if (num_bytes_read > 4) {
+ rc = -EIO;
+ goto exit_setprotocol;
+ }
break;
}
usleep_range(10000, 11000);