From patchwork Fri Sep 4 07:40:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lad Prabhakar X-Patchwork-Id: 11756155 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8181114F9 for ; Fri, 4 Sep 2020 07:41:05 +0000 (UTC) Received: from web01.groups.io (unknown [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B9DB206A5 for ; Fri, 4 Sep 2020 07:41:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.cip-project.org header.i=@lists.cip-project.org header.b="PiFkfF8Y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B9DB206A5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bp.renesas.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+5415+4520428+8129116@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id sbSyYY4521763xaoD26Wv2ie; Fri, 04 Sep 2020 00:41:02 -0700 X-Received: from relmlie5.idc.renesas.com (relmlie5.idc.renesas.com [210.160.252.171]) by mx.groups.io with SMTP id smtpd.web10.33362.1599205260815055849 for ; Fri, 04 Sep 2020 00:41:01 -0700 X-IronPort-AV: E=Sophos;i="5.76,388,1592838000"; d="scan'208";a="56369402" X-Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 04 Sep 2020 16:40:59 +0900 X-Received: from localhost.localdomain (unknown [10.226.36.204]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 77F974009673; Fri, 4 Sep 2020 16:40:58 +0900 (JST) From: "Lad Prabhakar" To: cip-dev@lists.cip-project.org, Nobuhiro Iwamatsu , Pavel Machek Cc: Biju Das Subject: [cip-dev] [PATCH 4.4.y-cip] gpio: rcar: Avoid NULL pointer access in gpio_rcar_set_multiple() Date: Fri, 4 Sep 2020 08:40:57 +0100 Message-Id: <20200904074057.27932-1-prabhakar.mahadev-lad.rj@bp.renesas.com> Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Delivered-To: mailing list cip-dev@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: iOYhVMJbYL7f7ejjOpQBwsXsx4520428AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1599205262; bh=VMHBMifABkn1C1auwxYY11IdYrElicaSNQ/PeeMDpys=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=PiFkfF8YKmK/oH5uyR2AM6Bg5hHwdBimR99qCMNufLl/xM58Jyatr0rORTflNRogquz CczVJBptFTnF3l8YF2XTs5rkJecIHhOMcGmrXyPSLup15CLEZsaKK18Z5GY5Eog7m5x8G lQScqma/BlpCBczjErP20lYAgyqgDTDcmNs= gpiochip_get_data() expects the controller probe to call gpiochip_add_data() before using it, where as the rcar-gpio driver probe has gpiochip_add() call thus resulting in NULL pointer access. Avoid this case by using gpio_to_priv() call. Fixes: 6e52cced1aa58 ("gpio: rcar: Implement gpiochip.set_multiple()") Signed-off-by: Lad Prabhakar --- drivers/gpio/gpio-rcar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index e829f11aca8f..2778dcd96ae7 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -352,7 +352,7 @@ static void gpio_rcar_set(struct gpio_chip *chip, unsigned offset, int value) static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { - struct gpio_rcar_priv *p = gpiochip_get_data(chip); + struct gpio_rcar_priv *p = gpio_to_priv(chip); unsigned long flags; u32 val, bankmask;