Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3109136pxm; Mon, 28 Feb 2022 12:11:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJymrxDjBrFQ/Y+7i4EklxzEjciGBw0bAgUDaWDpBZdHgxDOWCUOm86URQI8nig57SVnotkb X-Received: by 2002:a17:902:da90:b0:14f:dd4b:e65a with SMTP id j16-20020a170902da9000b0014fdd4be65amr22349004plx.37.1646079100366; Mon, 28 Feb 2022 12:11:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646079100; cv=none; d=google.com; s=arc-20160816; b=IwmYHkmkJqgw0kCNF59zkwBbr3mChHUGJSo0KQJC6J+XNy8hx8xiAPSOHpNqsnbJfj 8+OpHG9TOSHOpOnTOCc2UqPPpzjiU3JnsxPaHeapR15RMOcLbJcNokpOZyyw1jy5DGkM D3yQ7KOJt8tfGLl+yYWv0KBYxx4H44+bQpGdBgQ+6ajDGGm/PKlKdfcQAzfKJcxoc05R a3zYEQf4/vhhG65WSwPGehkeOm4YpAeNVCL+W2+PHWavoGLYFFqwrGKhevt1/varQ3pR xWga0TB3tudrLR5rURl7EAalaTof100l0vfpFhro0fIBn2ctydOn8f7XIE0U9+k8Adjr skww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=s3FQdNaE430Eviwv6w9n8va8qkssYnVQ/Y9y2qCqgo4=; b=L+M8K00+mcMf1rnkWYktImHQ2tc2GHRa9Xn7rll8ofKLDe1volC/vV3WDJplCSiKJh EPxZJZS9I1D3WLAWQIxFdGo0KOdkpGbckvKEXn/7Fn75y22rKqkO8i8EaIst1qo+hKyZ uotTkH2GXCur73E9KCIvYqM9/z0xIiippWsJh6sHCcvsj/hES1uZqrnn3YPCh4nVuFRV r2zbLGVrN7ysZatEfKMn2YVk/PVSFoBCGnJm4uVWFmXGzGoLXA3akBtwX+1tuU/fAcl7 s98A0NDgCZx9Mh61uZMq10K9g4YZyIy8vIhnxlU26voahZGrwucSvF+UK9sYpt/kPMUH yJJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LpeIn1x9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b8-20020a631b48000000b003644cfa0dd2si10056407pgm.141.2022.02.28.12.11.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Feb 2022 12:11:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LpeIn1x9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 92DBA154D22; Mon, 28 Feb 2022 11:35:06 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238123AbiB1RfE (ORCPT + 99 others); Mon, 28 Feb 2022 12:35:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238308AbiB1RdN (ORCPT ); Mon, 28 Feb 2022 12:33:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F078F983; Mon, 28 Feb 2022 09:29:47 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CEFB76145C; Mon, 28 Feb 2022 17:29:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D97CBC340F0; Mon, 28 Feb 2022 17:29:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1646069386; bh=vU/qhmC0dR0bSizI4ccziVaAU5ZeYpReprMKNESwoZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LpeIn1x9h1mQqQtoXTTRc/EAZvQEn+zHsSLmV9+B7SypScJGkN9nZs6W3XyQPtibr NfunRS+Ulol95mr61Rz1yjYZtcoavTmQG305IkmPoUEODeqx9AAB1ggk75dcrzQvin 0Li4u2q/4gNPnQqzMh65oatp9cTXS4fCFxKMfjhQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marc Zyngier , Thierry Reding , Linus Walleij , Bartosz Golaszewski Subject: [PATCH 4.19 17/34] gpio: tegra186: Fix chip_data type confusion Date: Mon, 28 Feb 2022 18:24:23 +0100 Message-Id: <20220228172209.845156606@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220228172207.090703467@linuxfoundation.org> References: <20220228172207.090703467@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier commit d1e972ace42390de739cde87d96043dcbe502286 upstream. The tegra186 GPIO driver makes the assumption that the pointer returned by irq_data_get_irq_chip_data() is a pointer to a tegra_gpio structure. Unfortunately, it is actually a pointer to the inner gpio_chip structure, as mandated by the gpiolib infrastructure. Nice try. The saving grace is that the gpio_chip is the first member of tegra_gpio, so the bug has gone undetected since... forever. Fix it by performing a container_of() on the pointer. This results in no additional code, and makes it possible to understand how the whole thing works. Fixes: 5b2b135a87fc ("gpio: Add Tegra186 support") Signed-off-by: Marc Zyngier Cc: Thierry Reding Cc: Linus Walleij Cc: Bartosz Golaszewski Link: https://lore.kernel.org/r/20220211093904.1112679-1-maz@kernel.org Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-tegra186.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/drivers/gpio/gpio-tegra186.c +++ b/drivers/gpio/gpio-tegra186.c @@ -237,9 +237,12 @@ static int tegra186_gpio_of_xlate(struct return offset + pin; } +#define to_tegra_gpio(x) container_of((x), struct tegra_gpio, gpio) + static void tegra186_irq_ack(struct irq_data *data) { - struct tegra_gpio *gpio = irq_data_get_irq_chip_data(data); + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio = to_tegra_gpio(gc); void __iomem *base; base = tegra186_gpio_get_base(gpio, data->hwirq); @@ -251,7 +254,8 @@ static void tegra186_irq_ack(struct irq_ static void tegra186_irq_mask(struct irq_data *data) { - struct tegra_gpio *gpio = irq_data_get_irq_chip_data(data); + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio = to_tegra_gpio(gc); void __iomem *base; u32 value; @@ -266,7 +270,8 @@ static void tegra186_irq_mask(struct irq static void tegra186_irq_unmask(struct irq_data *data) { - struct tegra_gpio *gpio = irq_data_get_irq_chip_data(data); + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio = to_tegra_gpio(gc); void __iomem *base; u32 value; @@ -281,7 +286,8 @@ static void tegra186_irq_unmask(struct i static int tegra186_irq_set_type(struct irq_data *data, unsigned int flow) { - struct tegra_gpio *gpio = irq_data_get_irq_chip_data(data); + struct gpio_chip *gc = irq_data_get_irq_chip_data(data); + struct tegra_gpio *gpio = to_tegra_gpio(gc); void __iomem *base; u32 value;