From patchwork Thu Nov 5 16:02:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Labbe X-Patchwork-Id: 540496 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8A9891409C4 for ; Fri, 6 Nov 2015 03:03:49 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=Wl/RROeC; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1033448AbbKEQCn (ORCPT ); Thu, 5 Nov 2015 11:02:43 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:37773 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033304AbbKEQCl (ORCPT ); Thu, 5 Nov 2015 11:02:41 -0500 Received: by wicfv8 with SMTP id fv8so12612033wic.0; Thu, 05 Nov 2015 08:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=zIndoC+PNo8NgjPrTdKvKBiJ1+Vp3q9SYi3Il+CSg9w=; b=Wl/RROeC3fvpdI1RovNiSiX11WIrh98n8zcuvCOCkSqNfg294OkN0rLDFENXwyZH0G E6xdVYwLDmOYZ+oBiGP6Jwy6XD0ohkS2cTXR3VC9jeamFqEXbvjiwAGnMRQKT6yWTQil BpGKFrscbd/jgBNmF+m/gtxvLBcRU7WzyLGbyoc+/xkbGDdaW8FxV50tBrTQ3kM0vNhz xYLBVTPnFpjv6bsYfN47v6hUNhDhuixgR+qudQ9hwMk1V0fLrwWnyV+Q5skx9S3WzP/X 1NYi7kFqfon/Vx8z2q75dG8i+Mp+9H+Gc0x3/pAuhzvH834n98ZT/sH2slhvpaGJCUA9 65jw== X-Received: by 10.194.116.167 with SMTP id jx7mr9370406wjb.105.1446739359618; Thu, 05 Nov 2015 08:02:39 -0800 (PST) Received: from Red.local (ANice-651-1-289-62.w83-201.abo.wanadoo.fr. [83.201.177.62]) by smtp.googlemail.com with ESMTPSA id u126sm34853885wmd.3.2015.11.05.08.02.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 05 Nov 2015 08:02:39 -0800 (PST) From: LABBE Corentin To: linus.walleij@linaro.org, gnurou@gmail.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, LABBE Corentin Subject: [PATCH] gpio: syscon: fix a possible NULL dereference Date: Thu, 5 Nov 2015 17:02:35 +0100 Message-Id: <1446739355-25849-1-git-send-email-clabbe.montjoie@gmail.com> X-Mailer: git-send-email 2.4.10 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org of_match_device could return NULL, and so cause a NULL pointer dereference later at line 199: priv->flags = of_id->data; Reported-by: coverity (CID 1324140) Signed-off-by: LABBE Corentin Reviewed-by: Alexandre Courbot --- drivers/gpio/gpio-syscon.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpio/gpio-syscon.c b/drivers/gpio/gpio-syscon.c index 045a952..e673c58 100644 --- a/drivers/gpio/gpio-syscon.c +++ b/drivers/gpio/gpio-syscon.c @@ -192,6 +192,9 @@ static int syscon_gpio_probe(struct platform_device *pdev) struct device_node *np = dev->of_node; int ret; + if (!of_id) + return -ENODEV; + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM;