From patchwork Sun Mar 4 12:45:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 881177 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bgdev.pl Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="bsLX0p+p"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zvN7V2zKgz9sX4 for ; Sun, 4 Mar 2018 23:45:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752606AbeCDMp4 (ORCPT ); Sun, 4 Mar 2018 07:45:56 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:35562 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752542AbeCDMpz (ORCPT ); Sun, 4 Mar 2018 07:45:55 -0500 Received: by mail-wr0-f193.google.com with SMTP id l43so14516700wrc.2 for ; Sun, 04 Mar 2018 04:45:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=CgC6xItOiJ3QBQFn+qYH33Kocis+59596v4VcU4+o4s=; b=bsLX0p+pb4OPbMBILH86Owep6a6Ph8PI4J/DL0hSWSvyQ4nVQKEl8BosD7K8Y7TDLV hfkfIp3mBlmEcnWfe2CsgcOhQ6di9i/WhPq+yrOsg1WJ5gbxroTTkRAuEsYonNUwC5Ki nnoKHnLeYAZ8B7K6wBYjzBEM+Jzhs4lRPtts089SvVOpBYkDkMHtwovxzbKOjW/zN6af 9Wa6y70SjjivFDuUij/1m0eo6YXAKeNV6+KkSS5IyRWpn9WOJF6y9M+BAu7ctWnDLQOz hva8FSNQb9ZC8km+ySuHY/h9QpeXXBE2U+bzo3vgxoNMohc9R++ShAJ5GYtwj9nGyQTF jxFg== 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=CgC6xItOiJ3QBQFn+qYH33Kocis+59596v4VcU4+o4s=; b=Jl2TrgRH3hoePFzTzHdOrnMaXlu40Lw/NKOYMKoc0fqq5L7xvcUB4TdHEaZILu8Awn JlriTwFf1t4bpLtWLmKdC1tG3IFIPkJRRXFH+kCAluUAiNDtj2y2fuVuFr6vpW0v5f5S fDiYX27vebqkfPHw+XvpepDj7j/D0XEIP1tjnaFqLk8D2HcbW2HE4nWA9KdJzQfWp5Zr b4SioVIFkfpYU1DvyQxz1bBcWhWNytBrIpBL6fNS6JUhs3D7gGWjZQcgRMmxjoDQ6vMA J+4e19tEx4ngo7MmUXTat1xObFtmBcDKeWtW/o9idaZ6dFmkdzIm/VBtmg6jQo+aE2ot 7dcQ== X-Gm-Message-State: APf1xPBP3o+NC+WgqVd0o9nFBNrLp2GKyBsUXCMq/nvgVP5eDAQfO5Ne JQNi2J8RIPl1ep3uPkTEq88M+g== X-Google-Smtp-Source: AG47ELsYfmobYxK6iKM2mFsQiNhSvECtUEyYnskf9OnREmM/ApFir6fqqVhyXn77US+ZpMtqQzmHJw== X-Received: by 10.223.199.71 with SMTP id b7mr10260021wrh.228.1520167554269; Sun, 04 Mar 2018 04:45:54 -0800 (PST) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id 43sm11565927wru.40.2018.03.04.04.45.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Mar 2018 04:45:53 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Bamvor Jian Zhang Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH] gpio: mockup: fix a potential crash when creating debugfs entries Date: Sun, 4 Mar 2018 13:45:51 +0100 Message-Id: <20180304124551.22565-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.16.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org If we failed to create the top debugfs directory, we must not try to create the child nodes. We currently only check if gpio_mockup_dbg_dir is not NULL, but it can also contain an errno if debugfs is disabled in build options. Use IS_ERR_OR_NULL() instead. Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-mockup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-mockup.c b/drivers/gpio/gpio-mockup.c index 3a545ad17817..b5876b07b0f7 100644 --- a/drivers/gpio/gpio-mockup.c +++ b/drivers/gpio/gpio-mockup.c @@ -314,7 +314,7 @@ static int gpio_mockup_probe(struct platform_device *pdev) if (rv) return rv; - if (gpio_mockup_dbg_dir) + if (!IS_ERR_OR_NULL(gpio_mockup_dbg_dir)) gpio_mockup_debugfs_setup(dev, chip); return 0;