fix kernel panic

This commit is contained in:
Fabian Montero 2024-10-18 23:28:41 -06:00
parent a73edd885d
commit e90f154cac
Signed by: fabian
GPG key ID: 1FFAC35E1798174F

View file

@ -441,7 +441,7 @@ exit_busy:
static void sx127x_poll_work(struct work_struct *work) static void sx127x_poll_work(struct work_struct *work)
{ {
u8 ack_flags, lqi, mode, read_flags, rx_base, *rx_data, rx_length; u8 ack_flags, lqi, mode, read_flags, rx_base, *rx_data, rx_length = 0;
bool do_rx = false, was_busy = false; bool do_rx = false, was_busy = false;
unsigned long spin_irq; unsigned long spin_irq;
struct sx127x *hw = container_of(work, struct sx127x, poll_work); struct sx127x *hw = container_of(work, struct sx127x, poll_work);
@ -492,15 +492,19 @@ static void sx127x_poll_work(struct work_struct *work)
if (sx127x_reg_write(hw, SX127X_REG_FIFO_ADDR_PTR, rx_base) < 0) if (sx127x_reg_write(hw, SX127X_REG_FIFO_ADDR_PTR, rx_base) < 0)
goto exit_busy; goto exit_busy;
rx_skb = dev_alloc_skb(IEEE802154_MTU); if (rx_length <= IEEE802154_MTU) {
if (!rx_skb) rx_skb = dev_alloc_skb(IEEE802154_MTU);
goto exit_busy; if (!rx_skb)
rx_data = skb_put(rx_skb, rx_length);
while (rx_length--)
if (sx127x_reg_read(hw, SX127X_REG_FIFO, rx_data++) < 0)
goto exit_busy; goto exit_busy;
rx_data = skb_put(rx_skb, rx_length);
while (rx_length--)
if (sx127x_reg_read(hw, SX127X_REG_FIFO, rx_data++) < 0)
goto exit_busy;
} else
dev_err(&hw->spi->dev, "%s: rx_length overflow: %u > IEEE802154_MTU\n", __func__, rx_length);
if (sx127x_reg_write(hw, SX127X_REG_FIFO_RX_BASE_ADDR, SX127X_FIFO_RX_BASE_ADDRESS) < 0) if (sx127x_reg_write(hw, SX127X_REG_FIFO_RX_BASE_ADDR, SX127X_FIFO_RX_BASE_ADDRESS) < 0)
goto exit_busy; goto exit_busy;
} }