Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3286513ybb; Tue, 31 Mar 2020 02:07:37 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtqHgUKVVWvUAyVHFyQIkV0fZ2mc1NU3wSOpEJ2q5Juk28JT6aBNRHCcdiWKzrQHVJEtNCk X-Received: by 2002:aca:b5c3:: with SMTP id e186mr1333132oif.114.1585645657319; Tue, 31 Mar 2020 02:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645657; cv=none; d=google.com; s=arc-20160816; b=M7qqFGebtpaXjxEqR7I77ikU4YuEqZl766ZBIyFjQT9LTyOseI8HheOaMOuyPIjQgS epjfd2TiL6nGczBWFw1SIrcidG/Qy9JL8t9zYM1br8UiKbJMo4KX/EZ6DjDF1VCRYjKK RYadA8bXyjQnjYkmPKX0Ll2SLoxsxWW6rsla8NhN4Ntexj5AeA6DEealu+aiDS9jwb6j VkB2dswoQHBum2QNTm+8eD6TKmcEaMQMigqQLVFjM+gYfPX2o/xhBWIcFxFVLyyDLWfS I3O097N/+AN42HY0H9Owi1L9CKwOyowQjqOsHsMtyY4NgakE+86puMkVzYsD9wC4ioO0 L8bg== 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=QgzP9HlGtup+a8cMRMYKJMPromKQ44FI5WlSrGmWgUU=; b=nXckD2e3JAgztCuraPxUs26eAMIgiRne0nqp7VV1e+dQq1wnjBVAQeprGvqN2M+xEw a8+kRiJtnN6/t32xbLgiqi6IPb0h78b0e2KLvZg3nH4ENavknYkl2VZugVgx+SAoMrOj VIRw9BTx0kxGXmZb7lMuNw4QuSPwnOM6i+wK/3Mrzww25R7RkIlfb9HE1NdJBTVB2Bh/ 7Cyu69IbcdozKH5zdr5ND5Tmfjt+I6kt0fb/T7QAadVdLViybE6WuOefNwQIV0J9vwVW R/RTI1EdhbF3eKqhcPcm2MvV0zHaxfKanOMpd+ao+qxn3CEkCLKLiBQf9L6SugNgov8U 1DFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gjTReSPt; 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 v7si7332218otp.43.2020.03.31.02.07.25; Tue, 31 Mar 2020 02:07:37 -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=gjTReSPt; 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 S1731099AbgCaJGA (ORCPT + 99 others); Tue, 31 Mar 2020 05:06:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:47142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730053AbgCaJFz (ORCPT ); Tue, 31 Mar 2020 05:05:55 -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 8EC9E20B1F; Tue, 31 Mar 2020 09:05:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645555; bh=UNYn8Ftm2U+xuoqzdwgc59OmLPnfj1sfx624GvHCahU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gjTReSPt/sUvnHZtOdNjmaOuCjdb8OVnPebpuNSnW3Ugjpu8SRKY8plQjapmlqu95 Vs0m1GX8lbRnr5hqiWiC9xE7HSY+j02jTZrRc2tSyrSEWEqg4un/aIZ31KYM5TOItS l4ZR3ogTUbpKp53T4LBS7Q59WKw+lwjkpW4cuWuk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Brian Masney , Hans Verkuil , Bartosz Golaszewski , Linus Walleij Subject: [PATCH 5.5 089/170] gpiolib: Fix irq_disable() semantics Date: Tue, 31 Mar 2020 10:58:23 +0200 Message-Id: <20200331085433.743228689@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Linus Walleij commit 8959b304c7062889b1276092cc8590dc1ba98f65 upstream. The implementation if .irq_disable() which kicks in between the gpiolib and the driver is not properly mimicking the expected semantics of the irqchip core: the irqchip will call .irq_disable() if that exists, else it will call mask_irq() which first checks if .irq_mask() is defined before calling it. Since we are calling it unconditionally, we get this bug from drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c, as it only defines .irq_mask_ack and not .irq_mask: Unable to handle kernel NULL pointer dereference at virtual address 00000000 pgd = (ptrval) (...) PC is at 0x0 LR is at gpiochip_irq_disable+0x20/0x30 Fix this by only calling .irq_mask() if it exists. Cc: Brian Masney Cc: Hans Verkuil Cc: stable@vger.kernel.org Reviewed-by: Bartosz Golaszewski Fixes: 461c1a7d4733 ("gpiolib: override irq_enable/disable") Signed-off-by: Linus Walleij Link: https://lore.kernel.org/r/20200306132326.1329640-1-linus.walleij@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -2323,9 +2323,16 @@ static void gpiochip_irq_disable(struct { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); + /* + * Since we override .irq_disable() we need to mimic the + * behaviour of __irq_disable() in irq/chip.c. + * First call .irq_disable() if it exists, else mimic the + * behaviour of mask_irq() which calls .irq_mask() if + * it exists. + */ if (chip->irq.irq_disable) chip->irq.irq_disable(d); - else + else if (chip->irq.chip->irq_mask) chip->irq.chip->irq_mask(d); gpiochip_disable_irq(chip, d->hwirq); }