sfc: fix null pointer dereference in efx_hard_start_xmit

Trying to get the channel from the tx_queue variable here is wrong
because we can only be here if tx_queue is NULL, so we shouldn't
dereference it. As the above comment in the code says, this is very
unlikely to happen, but it's wrong anyway so let's fix it.

I hit this issue because of a different bug that caused tx_queue to be
NULL. If that happens, this is the error message that we get here:
  BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
  [...]
  RIP: 0010:efx_hard_start_xmit+0x153/0x170 [sfc]

Fixes: 12804793b1 ("sfc: decouple TXQ type from label")
Reported-by: Tianhao Zhao <tizhao@redhat.com>
Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
Acked-by: Edward Cree <ecree.xilinx@gmail.com>
Link: https://lore.kernel.org/r/20220914111135.21038-1-ihuguet@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Íñigo Huguet 2022-09-14 13:11:35 +02:00 коммит произвёл Jakub Kicinski
Родитель f232af4295
Коммит 0a242eb291
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -549,7 +549,7 @@ netdev_tx_t efx_hard_start_xmit(struct sk_buff *skb,
* previous packets out. * previous packets out.
*/ */
if (!netdev_xmit_more()) if (!netdev_xmit_more())
efx_tx_send_pending(tx_queue->channel); efx_tx_send_pending(efx_get_tx_channel(efx, index));
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }