Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4561762pja; Thu, 21 Nov 2019 21:54:38 -0800 (PST) X-Google-Smtp-Source: APXvYqydswcK7UzCFuNSaHANsKlMwYRIpHIZ+nKf/vV7aInsNlyOcR6NlbRyTjA5P6nPS2QPk3Lr X-Received: by 2002:a17:906:8054:: with SMTP id x20mr19239522ejw.68.1574402078562; Thu, 21 Nov 2019 21:54:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402078; cv=none; d=google.com; s=arc-20160816; b=s8+beaviSeZ0emslkPVa2a2gqFi7Q2J0CEtTBqZnvkGDLVdhg1U2EOhGq2YJB9ZNzM NVXSQgqi3/5HqJc6PBoex0CGCGiTYLs6RusapxR6J2TYHy1BK6Etj8YlhJ4KZTLfTXmU BwFYVtQcKiJUqEjxbDYtQH9M2OWMsg87MwsFaYTbHiL8SQ441coy3qL/2CvcVoH2nLTx suzk/x6bnsla3XEIb/FeTgVlsCZrQbX/WbSOJIl544XFCWTJKxG0pPl5BD8rKh5I6M7V FxtCMNRKsyWJ6AqjvMAY2cFAbaz5PlRegkbuWydQyaaAy9gm9MIz2t24zsAekUCPHkv8 EM1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IdbfXnKh6XoWrwIcQ55MgdhqmF3CN8vt/yovA2oJNMI=; b=A11oOUIe3+wnGflUHB61ILEsLW2NQ48lXhEA9KbyLpVooX1LDCWnyx0sERQSqbmJWG iVe5k2rlWsGT9wfML4JKFtlZMaKAfd9fSyI2JlBCIll5gX/9EbmvFO2xq4fHSWPB812z EYur77k51Ag4MMwg6HBlFDPvjwjOrlxuN3Q2TBs3m5N5TX6/3+kRKBUywlC0qdrMUBqV AUQwaGLiB9/aTp6LAPHlc79+zvEo34F/NjlGSgCyib0gfisNkg0M5MufOuKRQeMJfwx0 0odw/4oCidNSZ6WGV9ZziPNvG21kQlgj9+2PXDltZBecTc07SD6i89TCFe2n6mzwgth1 BcbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q2L0S9Us; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si3342451ejy.239.2019.11.21.21.54.14; Thu, 21 Nov 2019 21:54:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q2L0S9Us; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728415AbfKVFwI (ORCPT + 99 others); Fri, 22 Nov 2019 00:52:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:57382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728366AbfKVFwA (ORCPT ); Fri, 22 Nov 2019 00:52:00 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A78112068F; Fri, 22 Nov 2019 05:51:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401920; bh=XrgJf33ZX605w5/MqKEYzTarUruBrWyg+SRbs6OYdtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2L0S9UsmAM8rDpfUDqYewUQjpjGJCiOHi0pq7PMK7ApcZNA7dKaIQZB9mEMdsGlK fQ6kpFO6ARUTiKujEvMMSALlieoMfJ+Y4sFpIcc9UPA1GCNhgZPxxOdEUol8wK1cNk iANZYb/l9Egc8HBZ2tSFIYBgpRNVFyEuWi2rI6n8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kangjie Lu , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 150/219] net: marvell: fix a missing check of acpi_match_device Date: Fri, 22 Nov 2019 00:48:02 -0500 Message-Id: <20191122054911.1750-143-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kangjie Lu [ Upstream commit 92ee77d148bf06d8c52664be4d1b862583fd5c0e ] When acpi_match_device fails, its return value is NULL. Directly using the return value without a check may result in a NULL-pointer dereference. The fix checks if acpi_match_device fails, and if so, returns -EINVAL. Signed-off-by: Kangjie Lu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c index 9b608d23ff7ee..9d95add05e3e6 100644 --- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c @@ -5131,6 +5131,8 @@ static int mvpp2_probe(struct platform_device *pdev) if (has_acpi_companion(&pdev->dev)) { acpi_id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); + if (!acpi_id) + return -EINVAL; priv->hw_version = (unsigned long)acpi_id->driver_data; } else { priv->hw_version = -- 2.20.1