From patchwork Mon Oct 31 11:30:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 689264 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t6sm85SSWz9t87 for ; Mon, 31 Oct 2016 22:37:28 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3t6sm84d4tzDvr8 for ; Mon, 31 Oct 2016 22:37:28 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from leibniz.telenet-ops.be (leibniz.telenet-ops.be [IPv6:2a02:1800:110:4::f00:d]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3t6scq4jq6zDvJS for ; Mon, 31 Oct 2016 22:31:07 +1100 (AEDT) Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by leibniz.telenet-ops.be (Postfix) with ESMTPS id 3t6scj48JfzMqthl for ; Mon, 31 Oct 2016 12:31:01 +0100 (CET) Received: from ayla.of.borg ([84.193.137.253]) by andre.telenet-ops.be with bizsmtp id 2BWv1u00j5UCtCs01BWvkj; Mon, 31 Oct 2016 12:31:00 +0100 Received: from ramsan.of.borg ([192.168.97.29] helo=ramsan) by ayla.of.borg with esmtp (Exim 4.82) (envelope-from ) id 1c1Ann-0003vq-FF; Mon, 31 Oct 2016 12:30:55 +0100 Received: from geert by ramsan with local (Exim 4.82) (envelope-from ) id 1c1Ant-0001PY-VU; Mon, 31 Oct 2016 12:31:01 +0100 From: Geert Uytterhoeven To: Arnd Bergmann , Greg Kroah-Hartman , Yangbo Lu , Simon Horman , Magnus Damm , Rob Herring , Mark Rutland Subject: [PATCH v2 3/7] base: soc: Check for NULL SoC device attributes Date: Mon, 31 Oct 2016 12:30:51 +0100 Message-Id: <1477913455-5314-4-git-send-email-geert+renesas@glider.be> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1477913455-5314-1-git-send-email-geert+renesas@glider.be> References: <1477913455-5314-1-git-send-email-geert+renesas@glider.be> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Dirk Behme , Geert Uytterhoeven , linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" If soc_device_match() is used to check the value of a specific attribute that is not present for the current SoC, the kernel crashes with a NULL pointer dereference. Fix this by explicitly checking for the absence of a needed property, and considering this a non-match. Signed-off-by: Geert Uytterhoeven Acked-by: Arnd Bergmann Acked-by: Greg Kroah-Hartman --- v2: - Add Acked-by. --- drivers/base/soc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 04ee597fc3a3fda0..dc26e5949a320223 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -176,19 +176,23 @@ static int soc_device_match_one(struct device *dev, void *arg) const struct soc_device_attribute *match = arg; if (match->machine && - !glob_match(match->machine, soc_dev->attr->machine)) + (!soc_dev->attr->machine || + !glob_match(match->machine, soc_dev->attr->machine))) return 0; if (match->family && - !glob_match(match->family, soc_dev->attr->family)) + (!soc_dev->attr->family || + !glob_match(match->family, soc_dev->attr->family))) return 0; if (match->revision && - !glob_match(match->revision, soc_dev->attr->revision)) + (!soc_dev->attr->revision || + !glob_match(match->revision, soc_dev->attr->revision))) return 0; if (match->soc_id && - !glob_match(match->soc_id, soc_dev->attr->soc_id)) + (!soc_dev->attr->soc_id || + !glob_match(match->soc_id, soc_dev->attr->soc_id))) return 0; return 1;