From mboxrd@z Thu Jan 1 00:00:00 1970 From: Subject: [PATCH V2 net 3/4] net: ena: fix NULL dereference due to untimely napi initialization Date: Tue, 9 Oct 2018 11:21:29 +0300 Message-ID: <1539073290-30270-4-git-send-email-akiyano@amazon.com> References: <1539073290-30270-1-git-send-email-akiyano@amazon.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Arthur Kiyanovski , , , , , , , , , , To: , Return-path: Received: from smtp-fw-4101.amazon.com ([72.21.198.25]:24976 "EHLO smtp-fw-4101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbeJIPhv (ORCPT ); Tue, 9 Oct 2018 11:37:51 -0400 In-Reply-To: <1539073290-30270-1-git-send-email-akiyano@amazon.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Arthur Kiyanovski napi poll functions should be initialized before running request_irq(), to handle a rare condition where there is a pending interrupt, causing the ISR to fire immediately while the poll function wasn't set yet, causing a NULL dereference. Fixes: 1738cd3ed342 ("net: ena: Add a driver for Amazon Elastic Network Adapters (ENA)") Signed-off-by: Arthur Kiyanovski --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index ce18e07..d906293 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -1575,8 +1575,6 @@ static int ena_up_complete(struct ena_adapter *adapter) if (rc) return rc; - ena_init_napi(adapter); - ena_change_mtu(adapter->netdev, adapter->netdev->mtu); ena_refill_all_rx_bufs(adapter); @@ -1730,6 +1728,13 @@ static int ena_up(struct ena_adapter *adapter) ena_setup_io_intr(adapter); + /* napi poll functions should be initialized before running + * request_irq(), to handle a rare condition where there is a pending + * interrupt, causing the ISR to fire immediately while the poll + * function wasn't set yet, causing a null dereference + */ + ena_init_napi(adapter); + rc = ena_request_io_irq(adapter); if (rc) goto err_req_irq; -- 2.7.4