]> git.baikalelectronics.ru Git - kernel.git/commit
net: mvneta: fix double free of txq->buf
authorTom Rix <trix@redhat.com>
Sat, 3 Oct 2020 18:51:21 +0000 (11:51 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 4 Oct 2020 22:07:19 +0000 (15:07 -0700)
commitb3283e931b7ea3f57ea5e15aafd71db853497242
tree6ce419440a2fbdceebe089c944e9d93cfcb890e7
parentd184f40c5c92d9922eef008bff4cc576767455b1
net: mvneta: fix double free of txq->buf

clang static analysis reports this problem:

drivers/net/ethernet/marvell/mvneta.c:3465:2: warning:
  Attempt to free released memory
        kfree(txq->buf);
        ^~~~~~~~~~~~~~~

When mvneta_txq_sw_init() fails to alloc txq->tso_hdrs,
it frees without poisoning txq->buf.  The error is caught
in the mvneta_setup_txqs() caller which handles the error
by cleaning up all of the txqs with a call to
mvneta_txq_sw_deinit which also frees txq->buf.

Since mvneta_txq_sw_deinit is a general cleaner, all of the
partial cleaning in mvneta_txq_sw_deinit()'s error handling
is not needed.

Fixes: 530b43037fd2 ("net: mvneta: Implement software TSO")
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvneta.c