]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging: et131x: zero allocation of fbr to prevent random address access
authorMark Einon <mark.einon@gmail.com>
Tue, 23 Sep 2014 19:41:11 +0000 (20:41 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 24 Sep 2014 06:38:15 +0000 (23:38 -0700)
If et131x_rx_dma_memory_alloc() allocates rx_ring->fbr[0] but fails to
allocate rx_ring->fbr[1], this leaves fbr[0]->ring_virtaddr with the
possibility of being accessed in et131x_rx_dma_memory_free() as it
contains a random value, potentially causing an oops.

Fix this by zeroing the fbr memory on allocation. Subsequent frees of
this fbr memory explicitly zeros the ring_virtaddr value.

Reported-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/et131x/et131x.c

index 93afd61f33fd2b866d40a103a5fa2443b244c522..2889f86e605226b9069656c78bdc029fc7d53fa3 100644 (file)
@@ -2003,10 +2003,10 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
        struct fbr_lookup *fbr;
 
        /* Alloc memory for the lookup table */
-       rx_ring->fbr[0] = kmalloc(sizeof(*fbr), GFP_KERNEL);
+       rx_ring->fbr[0] = kzalloc(sizeof(*fbr), GFP_KERNEL);
        if (rx_ring->fbr[0] == NULL)
                return -ENOMEM;
-       rx_ring->fbr[1] = kmalloc(sizeof(*fbr), GFP_KERNEL);
+       rx_ring->fbr[1] = kzalloc(sizeof(*fbr), GFP_KERNEL);
        if (rx_ring->fbr[1] == NULL)
                return -ENOMEM;