summaryrefslogtreecommitdiffstats
path: root/drivers/net/tokenring/ibmtr.c
diff options
context:
space:
mode:
authorroel kluin <roel.kluin@gmail.com>2009-10-03 11:26:55 +0000
committerDavid S. Miller <davem@davemloft.net>2009-10-29 22:49:17 -0700
commit18eb0893c12898253c18ba23b51a6ea9a07ba4c7 (patch)
tree5fa3b24c55d520a6554f00eaef872c40d24328e7 /drivers/net/tokenring/ibmtr.c
parentb0c110ca8e89f2c9cd52ec7fb1b98c5b7aa78496 (diff)
downloadblackbird-op-linux-18eb0893c12898253c18ba23b51a6ea9a07ba4c7.tar.gz
blackbird-op-linux-18eb0893c12898253c18ba23b51a6ea9a07ba4c7.zip
ibmtr: possible Read buffer overflow?
Prevent read outside array bounds. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tokenring/ibmtr.c')
-rw-r--r--drivers/net/tokenring/ibmtr.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index 525bbc5b9c9d..6a3c7510afd9 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -1143,9 +1143,16 @@ static void dir_open_adapter (struct net_device *dev)
} else {
char **prphase = printphase;
char **prerror = printerror;
+ int pnr = err / 16 - 1;
+ int enr = err % 16 - 1;
DPRINTK("TR Adapter misc open failure, error code = ");
- printk("0x%x, Phase: %s, Error: %s\n",
- err, prphase[err/16 -1], prerror[err%16 -1]);
+ if (pnr < 0 || pnr >= ARRAY_SIZE(printphase) ||
+ enr < 0 ||
+ enr >= ARRAY_SIZE(printerror))
+ printk("0x%x, invalid Phase/Error.", err);
+ else
+ printk("0x%x, Phase: %s, Error: %s\n", err,
+ prphase[pnr], prerror[enr]);
printk(" retrying after %ds delay...\n",
TR_RETRY_INTERVAL/HZ);
}
OpenPOWER on IntegriCloud