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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B3370C4332F for ; Mon, 14 Nov 2022 14:17:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:CC:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RzN2zKD/HKi0pDAz9NnAlAn3PGf8D8UxXRBR/jmdvtI=; b=EEZfZk2sUYqptm tdC8A6rRUvZmSb3VZ+/2uCDUZvt4VZGnbPoPecRGFiRsyQkJyxgR0LNxt/VNZuFvOgBInqzni7wMW 0qU03DrIoaRai0GFRQV9f/J9BAYH8AwQQHQJk5sJV40vyeiVKk3ABOnFv5Wj/50eyN7xxyUEIFCba HsLkaKQmDUtO7ymJK/1gDv1fErSei6RIXyq45KHV2rB4As1QlrOVtB9CbesB70ZCSCZshmUOX3Reo Q78I6HhXfvrIhdSPYVpYFa7JZEa/pVjwbhPEPapC+Ok1moF7B3BNqCQKKheeeazTu+C/L6ThSVEr2 EgILkNJ+xwWWbKiJ3ThQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouaFW-001d77-4j; Mon, 14 Nov 2022 14:15:46 +0000 Received: from esa.microchip.iphmx.com ([68.232.153.233]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ouaFR-001d3p-LW for linux-arm-kernel@lists.infradead.org; Mon, 14 Nov 2022 14:15:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1668435343; x=1699971343; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=lz5QexcZR7yb/2bESAmF5qRLJcz/sjAk91e7262IrT0=; b=xrPOgenewyLS/dMPY5BApmFfBe84ube/ZlzDGApQayLXgsQJW91Dd0I6 78Z9ermC1WZGyBaX3TQnAQzDXC3QTGvKFnssT43SgXkewEiGbcb2K0Jda Kc3zBGL+abrlg8/zN6p+BX/irKJ3sDC/tZlsk+exwiTR0tB5dpARXEu7/ g98WUMGJNf6WmduN/RLo8QhJRDTUq1rQtVsRrk27J73Auq6GCaCpORrTW 0sKsYKikuJCTq9E8WnQefZfi6BM+b00gA6c69uCupPaT/oG7Q1Ls/Z7dR 8OBbQI14uOGNU1Xj+ZNDwjmcW9iYbX+mpxZF6TZwtyPqReazW2u8pq7XB A==; X-IronPort-AV: E=Sophos;i="5.96,161,1665471600"; d="scan'208";a="188894838" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 14 Nov 2022 07:15:32 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Mon, 14 Nov 2022 07:15:30 -0700 Received: from localhost (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Mon, 14 Nov 2022 07:15:30 -0700 Date: Mon, 14 Nov 2022 15:20:17 +0100 From: Horatiu Vultur To: Shang XiaoJing CC: , , , , , , , , , , , , Subject: Re: [PATCH 1/2] net: lan966x: Fix potential null-ptr-deref in lan966x_stats_init() Message-ID: <20221114142017.bqaeabujh4rlxl5c@soft-dev3-1> References: <20221114133853.5384-1-shangxiaojing@huawei.com> <20221114133853.5384-2-shangxiaojing@huawei.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221114133853.5384-2-shangxiaojing@huawei.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221114_061541_730474_E75D6EB1 X-CRM114-Status: GOOD ( 14.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The 11/14/2022 21:38, Shang XiaoJing wrote: > [Some people who received this message don't often get email from shangxiaojing@huawei.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ] > > lan966x_stats_init() calls create_singlethread_workqueue() and not > checked the ret value, which may return NULL. And a null-ptr-deref may > happen: > > lan966x_stats_init() > create_singlethread_workqueue() # failed, lan966x->stats_queue is NULL > queue_delayed_work() > queue_delayed_work_on() > __queue_delayed_work() # warning here, but continue > __queue_work() # access wq->flags, null-ptr-deref > > Check the ret value and return -ENOMEM if it is NULL. It looks good to me. Reviewed-by: Horatiu Vultur > > Fixes: 12c2d0a5b8e2 ("net: lan966x: add ethtool configuration and statistics") > Signed-off-by: Shang XiaoJing > --- > drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c > index e58a27fd8b50..0fb0efc224be 100644 > --- a/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c > +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ethtool.c > @@ -708,6 +708,9 @@ int lan966x_stats_init(struct lan966x *lan966x) > snprintf(queue_name, sizeof(queue_name), "%s-stats", > dev_name(lan966x->dev)); > lan966x->stats_queue = create_singlethread_workqueue(queue_name); > + if (!lan966x->stats_queue) > + return -ENOMEM; > + > INIT_DELAYED_WORK(&lan966x->stats_work, lan966x_check_stats_work); > queue_delayed_work(lan966x->stats_queue, &lan966x->stats_work, > LAN966X_STATS_CHECK_DELAY); > -- > 2.17.1 > -- /Horatiu _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel