]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
MUSB: Add sanity check for maximum number of endpoints
authorKevin Hilman <khilman@deeprootsystems.com>
Mon, 15 Sep 2008 10:09:31 +0000 (12:09 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 17 Oct 2008 21:40:58 +0000 (14:40 -0700)
There is no check if platform code passes in more endpoints (num_eps)
than the maximum number of enpoints (MUSB_C_NUM_EPS.)  The result is
that allocate_instance() happily writes past the end of 'struct musb'
corrupting memory.

This patch adds a BUG() if the platform code requests more than the max.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Acked-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/musb/musb_core.c

index 128e949db47c4a2c64f0156a2c7c227ef8f16fd1..bd82253a3329014803a35541135a008b93f82b57 100644 (file)
@@ -1806,6 +1806,7 @@ allocate_instance(struct device *dev,
        musb->ctrl_base = mbase;
        musb->nIrq = -ENODEV;
        musb->config = config;
+       BUG_ON(musb->config->num_eps > MUSB_C_NUM_EPS);
        for (epnum = 0, ep = musb->endpoints;
                        epnum < musb->config->num_eps;
                        epnum++, ep++) {