Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp611665img; Fri, 22 Mar 2019 05:08:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqzvCFi6q5KyPRldA0JoQLJXV339eDNPGlRpwoADURfhXEHrusp9eSvQu3Y9R9TO7KsB7fgp X-Received: by 2002:a17:902:d70f:: with SMTP id w15mr9211034ply.234.1553256513814; Fri, 22 Mar 2019 05:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256513; cv=none; d=google.com; s=arc-20160816; b=glhcMf/XHeWMcSZRWrmUYLcJDaRqHrSzxxklsMJP7Kc5pls8g21WpK0Bo4/CvKsG+7 hemv6D0F6kSowS96/UkVYkkhzJh1bqCUpe7hlrlX3qScqHFq41wneAX8G0WfysaNfNPu 9/auRw+tHihwos2/kAOIPKrzsCxD3L7YnyJCqE3XQsJ4KZWC/mJjUI5e+HVgJ0xYoU7l QPdUK08JUWTcTqntpK01HVxnWprvdzj9pcfJpc2ktZcT8DC6Ldj39wu5lr/5yC4p7Edp HvCzFTACN2kxOsSMO33TpuDEgVIgS18m0uiomHRp7rc1FhvNXERB9FMXH2gdP9GS3PLS g4Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pmxv0n2JYJPfyN4gkJfHL3weJwKmET9Ao2AebuzxVyY=; b=Ea39v8lf4xVkTRlbRF8ohNKQcCfUCoSC5ThiiKKA1WdlfHkC+UgJWI93fh4ENFbRm1 /R5ikRHvASKmB4ZJVMhUttHZN/zJOh4XXHHySW2VhqZMVj0fwAConQfZWqyQ+lXTsbzw zLqQG1VRX0KUJhkJAf6BfZCJSTQ8s41ZqB8ijVcbBhkQo3E9SaUDDr2lCAcC9OhFrPWw rU6MFKM/6UpcdSbqRFHkgHKK4NVKDDA3vm/oCzX4oMnemDUUqe2aRhq5tmjidDN/gpYG BNEpP7iLwLjdFKKiEMe1Jcata01cd6FW376W1supBDcjYAd/uGa+TWc5VzolBAq7UmnJ Ex7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WM3feymX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i69si6941753plb.75.2019.03.22.05.08.16; Fri, 22 Mar 2019 05:08:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WM3feymX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389024AbfCVMHX (ORCPT + 99 others); Fri, 22 Mar 2019 08:07:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:45700 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389011AbfCVMHQ (ORCPT ); Fri, 22 Mar 2019 08:07:16 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 071FD2082C; Fri, 22 Mar 2019 12:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256435; bh=SlmMQn8UKjqxEKFtDrGA2kG96/vOXNGq0ql6KTE4eVE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WM3feymXiPpBMqbiB6bPDnPuBd9CzqxuG05VGFNplqQdU/CuiZb+dfhbkTqm4t/Bj faUsRDRlAbHnA8uUyMgxDH/pBVjRFPOm2XYUiPQpsN9hWxBqFFd0tQ7y5nB/xIreO8 eEnVHu0C54REloR0DhVMuFEhY8TFP733s4/6P77g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Walton , Bartosz Golaszewski , Linus Walleij Subject: [PATCH 4.19 209/280] gpio: pca953x: Fix dereference of irq data in shutdown Date: Fri, 22 Mar 2019 12:16:02 +0100 Message-Id: <20190322111332.450517669@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Walton commit c378b3aa015931a46c91d6ccc2fe04d97801d060 upstream. If a PCA953x gpio was used as an interrupt and then released, the shutdown function was trying to extract the pca953x_chip pointer directly from the irq_data, but in reality was getting the gpio_chip structure. The net effect was that the subsequent writes to the data structure corrupted data in the gpio_chip structure, which wasn't immediately obvious until attempting to use the GPIO again in the future, at which point the kernel panics. This fix correctly extracts the pca953x_chip structure via the gpio_chip structure, as is correctly done in the other irq functions. Fixes: 0a70fe00efea ("gpio: pca953x: Clear irq trigger type on irq shutdown") Cc: stable@vger.kernel.org Signed-off-by: Mark Walton Reviewed-by: Bartosz Golaszewski Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-pca953x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -543,7 +543,8 @@ static int pca953x_irq_set_type(struct i static void pca953x_irq_shutdown(struct irq_data *d) { - struct pca953x_chip *chip = irq_data_get_irq_chip_data(d); + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct pca953x_chip *chip = gpiochip_get_data(gc); u8 mask = 1 << (d->hwirq % BANK_SZ); chip->irq_trig_raise[d->hwirq / BANK_SZ] &= ~mask;