Skip to content

Commit e112eb5

Browse files
einonmgregkh
authored andcommitted
staging: et131x: zero allocation of fbr to prevent random address access
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>
1 parent bfe945c commit e112eb5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/staging/et131x/et131x.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,10 +2003,10 @@ static int et131x_rx_dma_memory_alloc(struct et131x_adapter *adapter)
20032003
struct fbr_lookup *fbr;
20042004

20052005
/* Alloc memory for the lookup table */
2006-
rx_ring->fbr[0] = kmalloc(sizeof(*fbr), GFP_KERNEL);
2006+
rx_ring->fbr[0] = kzalloc(sizeof(*fbr), GFP_KERNEL);
20072007
if (rx_ring->fbr[0] == NULL)
20082008
return -ENOMEM;
2009-
rx_ring->fbr[1] = kmalloc(sizeof(*fbr), GFP_KERNEL);
2009+
rx_ring->fbr[1] = kzalloc(sizeof(*fbr), GFP_KERNEL);
20102010
if (rx_ring->fbr[1] == NULL)
20112011
return -ENOMEM;
20122012

0 commit comments

Comments
 (0)