From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 559A7C433DF for ; Tue, 26 May 2020 19:07:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24B0B208A7 for ; Tue, 26 May 2020 19:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590520057; bh=oD6QkaIiaB6T+NAYwiJNPKDUYhK9EsRqwVgi97qBXfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=K+l+nmDRvRQcO3RcZPDzcs5o5OaFU3GfQYYkj2Qjpym/GRsBrsFyV1HQZH+YfGmPq Hp8DtpWl7b7phYUv0ONxwqWYXYgiV6AwdC1I9QfBH47h7wuqKxg1G/7UirTw9JeJni t4/Fyt5N4MAhChLZErQ05NfHzEz8CAciQK0+3LDE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391702AbgEZTHg (ORCPT ); Tue, 26 May 2020 15:07:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:36236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391604AbgEZTHb (ORCPT ); Tue, 26 May 2020 15:07:31 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6579A208A7; Tue, 26 May 2020 19:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590520050; bh=oD6QkaIiaB6T+NAYwiJNPKDUYhK9EsRqwVgi97qBXfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qb/o+04Dw7kGmgwvbeawwp7+5AcLoXWLAGQjUg2VKtJmyeEjEDyWnyj7RCHdYo0uS N0nBE+0KAQHIjqXsGs3euU+9X+fPb0HE97UsykTl4Slks1P3RmL/6qurFlnWLRuNHp w8JAvMzvHsI0z8rnWUxz0MFdXm33LfhqUzgeO760= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Petrov , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 040/111] stmmac: fix pointer check after utilization in stmmac_interrupt Date: Tue, 26 May 2020 20:52:58 +0200 Message-Id: <20200526183936.724509476@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183932.245016380@linuxfoundation.org> References: <20200526183932.245016380@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maxim Petrov [ Upstream commit f42234ffd531ca6b13d9da02faa60b72eccf8334 ] The paranoidal pointer check in IRQ handler looks very strange - it really protects us only against bogus drivers which request IRQ line with null pointer dev_id. However, the code fragment is incorrect because the dev pointer is used before the actual check which leads to undefined behavior. Remove the check to avoid confusing people with incorrect code. Signed-off-by: Maxim Petrov Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 89a6ae2b17e3..1623516efb17 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -3832,7 +3832,7 @@ static int stmmac_set_features(struct net_device *netdev, /** * stmmac_interrupt - main ISR * @irq: interrupt number. - * @dev_id: to pass the net device pointer. + * @dev_id: to pass the net device pointer (must be valid). * Description: this is the main driver interrupt service routine. * It can call: * o DMA service routine (to manage incoming frame reception and transmission @@ -3856,11 +3856,6 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id) if (priv->irq_wake) pm_wakeup_event(priv->device, 0); - if (unlikely(!dev)) { - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__); - return IRQ_NONE; - } - /* Check if adapter is up */ if (test_bit(STMMAC_DOWN, &priv->state)) return IRQ_HANDLED; -- 2.25.1