Skip to content

Commit 7bb26ea

Browse files
cailPaolo Abeni
authored andcommitted
net: atlantic: fix double free in ring reinit logic
Driver has a logic leak in ring data allocation/free, where double free may happen in aq_ring_free if system is under stress and driver init/deinit is happening. The probability is higher to get this during suspend/resume cycle. Verification was done simulating same conditions with stress -m 2000 --vm-bytes 20M --vm-hang 10 --backoff 1000 while true; do sudo ifconfig enp1s0 down; sudo ifconfig enp1s0 up; done Fixed by explicitly clearing pointers to NULL on deallocation Fixes: 018423e ("net: ethernet: aquantia: Add ring support code") Reported-by: Linus Torvalds <[email protected]> Closes: https://lore.kernel.org/netdev/CAHk-=wiZZi7FcvqVSUirHBjx0bBUZ4dFrMDVLc3+3HCrtq0rBA@mail.gmail.com/ Signed-off-by: Igor Russkikh <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 189ff16 commit 7bb26ea

File tree

1 file changed

+4
-1
lines changed
  • drivers/net/ethernet/aquantia/atlantic

1 file changed

+4
-1
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_ring.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,11 +938,14 @@ void aq_ring_free(struct aq_ring_s *self)
938938
return;
939939

940940
kfree(self->buff_ring);
941+
self->buff_ring = NULL;
941942

942-
if (self->dx_ring)
943+
if (self->dx_ring) {
943944
dma_free_coherent(aq_nic_get_dev(self->aq_nic),
944945
self->size * self->dx_size, self->dx_ring,
945946
self->dx_ring_pa);
947+
self->dx_ring = NULL;
948+
}
946949
}
947950

948951
unsigned int aq_ring_fill_stats_data(struct aq_ring_s *self, u64 *data)

0 commit comments

Comments
 (0)