From patchwork Tue Mar 12 07:32:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kangjie Lu X-Patchwork-Id: 10848647 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CC066C2 for ; Tue, 12 Mar 2019 07:32:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2081228448 for ; Tue, 12 Mar 2019 07:32:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F3FA28620; Tue, 12 Mar 2019 07:32:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E437E28448 for ; Tue, 12 Mar 2019 07:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=EB/n1yYvSYn+CKueHT/Gss1ukFD19fuDwfJvVb3nYPc=; b=brq mwJR0r1p3bJBs75sC5aJ8rf4ebpFTQA0q35Yt6rA8DgOJycD1pr0ULQuQjqMXmIWUdj1DbZ5o3S3E +6HECDqgXRGGIneMEmqFU4JEs8/BSrGEcPvfAshQWZ7iuuOfwV/2GCWXgSe8Yhw5B9ufI8K9S83PT 3CZcz4AwZtCPNyydRUVay2+HXh9fASrWM2NNk53iR9dudzNNKZedxev5qX6Fb+ywon46SZj+spiM9 VnGB2vj37iqodzGGOO5CMVfJqMEiz/b6UDw9RoZiAx5r2zy/gYx4xhp9TMzbP5uch5V8/VB2ycIGo XqHt5I/WPo/aHbijo7WSwSR9s0uEJ2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3bu9-00052Z-BB; Tue, 12 Mar 2019 07:32:53 +0000 Received: from mta-p6.oit.umn.edu ([134.84.196.206]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3bu5-00051z-CE for linux-arm-kernel@lists.infradead.org; Tue, 12 Mar 2019 07:32:50 +0000 Received: from localhost (unknown [127.0.0.1]) by mta-p6.oit.umn.edu (Postfix) with ESMTP id 8CEDDA32 for ; Tue, 12 Mar 2019 07:32:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p6.oit.umn.edu ([127.0.0.1]) by localhost (mta-p6.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nXImKvFtnBzN for ; Tue, 12 Mar 2019 02:32:48 -0500 (CDT) Received: from mail-it1-f197.google.com (mail-it1-f197.google.com [209.85.166.197]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p6.oit.umn.edu (Postfix) with ESMTPS id 5B189B3C for ; Tue, 12 Mar 2019 02:32:48 -0500 (CDT) Received: by mail-it1-f197.google.com with SMTP id j127so1454651itj.7 for ; Tue, 12 Mar 2019 00:32:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=WQP8GztQ+lsJ0g2nITx8iCV6S9LfwdKk+S7ZJ/ceSj8=; b=LXAin0Bcwme3Kl+QMcsLoGyExujOPVOKrtL59g+k+7Ovhjje5LCpfjwpuHhbPNqtrs akRNoJUTu5QkYnD+2ABqL23pfagixo3eV1tMK46WCf7ed/ao6lx1WlLMm5DK5+VrR1RY /9ZH85W6GLyXiK8P0xnExBdoeUAz2Tj0lNzDmWv2CsCgdHGcQsvjp0G56THbcJiCDkOe CYOZmrXNWWvBXMDwiIwm/OYresBtaBOzu54dT2wTId3vC+BLJuXYYuA81hMiDU5W96w1 ean+UCAN7CF0XyrwqEJpmGtVdCN27rrp7X0hyv/U3z5rressMNTMCJiPvifzWu9Vo/T6 B+5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=WQP8GztQ+lsJ0g2nITx8iCV6S9LfwdKk+S7ZJ/ceSj8=; b=Ex9N3PjEz3pnr600oTvYGrLRXhcQWCjz9H3gfzFr7zwbu72FrOqXUnjiYLqnKRInTx N9JcXvINF1yD9JLnrtovdPZAWMtp6TE6+I6Z1eofcpEAxMpnsX1Ti8FXtZ4f3VuD2p+4 XxIzP66W3NslmH6O22tUIQYC8SVgMXKy+f9P2IioseIHixs117iGbVoeB1adjjgEuEHd BvOWFG6YviMGvgg+CcTdBk+wL7Hgr/NkZxDbIcopzkfpOGQXagFGFWuE+Cfuqnva9nm0 vnsQowHDN51ra7iOiQq9Y4I23ceiXrTIWgbTvu8jtjpqdJS5VJ3DZgU0+K0ck5s9Kf5U 00Yg== X-Gm-Message-State: APjAAAVii1nNwRFhS1av6h/fiRIWmxWQIJAgG0wIRd+QBUi+2x9qTnLd T5l54xz9Dje/53w2m6S+L6d5GArrZDREG9aDzbGuodCe2xmxfVMT5MAEDaLSvvNa+0N8VC9Zitq 7vyZdu3aR9BKRq5cB60OJpMLxeHrkyqSNgNx+gcc= X-Received: by 2002:a02:3806:: with SMTP id b6mr20075507jaa.60.1552375967914; Tue, 12 Mar 2019 00:32:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqiyIM5PGhtk/zvEzfP/SY0s3p5KfUYhRaggAuLXI4qErUf54VQKwPuXyPrAyC9Al1LySj7g== X-Received: by 2002:a02:3806:: with SMTP id b6mr20075498jaa.60.1552375967677; Tue, 12 Mar 2019 00:32:47 -0700 (PDT) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id 187sm963994itl.27.2019.03.12.00.32.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Mar 2019 00:32:47 -0700 (PDT) From: Kangjie Lu To: kjlu@umn.edu Subject: [PATCH] net: stmmac: fix a potential NULL pointer dereference Date: Tue, 12 Mar 2019 02:32:41 -0500 Message-Id: <20190312073241.27495-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_003249_497371_3C760ED8 X-CRM114-Status: GOOD ( 10.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Torgue , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Jose Abreu , Maxime Coquelin , pakki001@umn.edu, Giuseppe Cavallaro , "David S. Miller" , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In case of_device_get_match_data fails, the fix return -ENOMEM to avoid the NULL pointer dereference. Signed-off-by: Kangjie Lu Reviewed-by: Mukesh Ojha --- drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c index 3256e5cbad27..344ead5949b1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c @@ -485,6 +485,8 @@ static int dwc_eth_dwmac_remove(struct platform_device *pdev) int err; data = of_device_get_match_data(&pdev->dev); + if (!data) + return -EINVAL; err = stmmac_dvr_remove(&pdev->dev); if (err < 0)