Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3925978imm; Mon, 8 Oct 2018 11:48:06 -0700 (PDT) X-Google-Smtp-Source: ACcGV62F9DUdiDj+ACG4Ouz6Y7UfNXB9XFGnj8+6kGxnesCzZfiIovyAhAhdQ3wSnRzfFR4naxXF X-Received: by 2002:a17:902:a40c:: with SMTP id p12-v6mr25411607plq.165.1539024486332; Mon, 08 Oct 2018 11:48:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539024486; cv=none; d=google.com; s=arc-20160816; b=Ur0tUssglxKJuBdSmWXZqDvkmYTd2SNp6cd4MjfDWATBiKaJFgcb0KlLJcxarV9J2d /zIFhzWIWV264oJgw+8xFX+K8B4CkuucLDB4Tv1RST0w2QchY0HkTHkzWplKU3IrCLQs kg13UV4Ga4zp+dH8yq92Uk1w+7pL6zCHIQajEjMp1N/JJSwIcoeyOLK4LdBnCDfrnpLM iKbkPjBtQsd49E40RadpALFXMKS83cfYA8hs/3q0OgsMI9aqU/8xguY21de+/I9CoXSj tgMlLwni6iHpxkYsvsjO/nmhdKFhIdXUErzEbulZZMxO1H40+tynLuWgLXswg5OChrgD +RIw== 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=jW4R0YrsNdruX7Uk12jUPzxiDikIMWdW/UiclllLNCg=; b=VP8Rb2b0re5Cdw+2dZ7NLArojPUa6TUyKlrLKMNofYiZ4hQxJtq83NSozXlYlJnENr oFC103A8/gRkMZkpeaoF444TeP9MAg1YBR/mUFGALdRYY9yzMxtS2fokI6ioShFhBf7l oa3ceBrwIzhPLw2tOJPd3l2yIrgr/58nSo9kJ3aCcYkWWvpKtYfj5CnZiM5hGO/PTSR3 VO2Dby0fo0zO1YMNJzYEDT/LZgYdZUWCJpmMUFvv9NuEz0/OmgafmVovZRpNeBUMGumB UBbLfb3xaCi5MovOU7fweaoOSKOq5FhTCkiX4YcfnJKRS5AwqD1zSl/D+vLk+useAMaH 1sNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u7S+YB7u; 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 16-v6si23937960pfc.21.2018.10.08.11.47.51; Mon, 08 Oct 2018 11:48:06 -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=u7S+YB7u; 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 S1731202AbeJIB70 (ORCPT + 99 others); Mon, 8 Oct 2018 21:59:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:47686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728570AbeJIB70 (ORCPT ); Mon, 8 Oct 2018 21:59:26 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 C82B02064A; Mon, 8 Oct 2018 18:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024380; bh=98QuUgFbB2jMqVe5Sl2qoOYGtZXPgQOWeaRvZnGWw14=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u7S+YB7u1JOwjZd2QFSSHD0ihSV+sfVPU07TA9SXVUBz4y9vbitJYszRWeBa79SSH GPsTDNn39gR17q3jgVG0GAYW1MNjXtIq0sxvpaFqfhcT4UdprYBPeu3zS03gCD1eV3 vj2lZn04LciXlFxQM+E9Vj91vqm4wawLgxbGIbAY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jia-Ju Bai , Michael Hennerich , Linus Walleij , Sasha Levin Subject: [PATCH 4.18 022/168] gpio: adp5588: Fix sleep-in-atomic-context bug Date: Mon, 8 Oct 2018 20:30:02 +0200 Message-Id: <20181008175620.888716198@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Hennerich [ Upstream commit 6537886cdc9a637711fd6da980dbb87c2c87c9aa ] This fixes: [BUG] gpio: gpio-adp5588: A possible sleep-in-atomic-context bug in adp5588_gpio_write() [BUG] gpio: gpio-adp5588: A possible sleep-in-atomic-context bug in adp5588_gpio_direction_input() Reported-by: Jia-Ju Bai Signed-off-by: Michael Hennerich Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpio-adp5588.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) --- a/drivers/gpio/gpio-adp5588.c +++ b/drivers/gpio/gpio-adp5588.c @@ -41,6 +41,8 @@ struct adp5588_gpio { uint8_t int_en[3]; uint8_t irq_mask[3]; uint8_t irq_stat[3]; + uint8_t int_input_en[3]; + uint8_t int_lvl_cached[3]; }; static int adp5588_gpio_read(struct i2c_client *client, u8 reg) @@ -173,12 +175,28 @@ static void adp5588_irq_bus_sync_unlock( struct adp5588_gpio *dev = irq_data_get_irq_chip_data(d); int i; - for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) + for (i = 0; i <= ADP5588_BANK(ADP5588_MAXGPIO); i++) { + if (dev->int_input_en[i]) { + mutex_lock(&dev->lock); + dev->dir[i] &= ~dev->int_input_en[i]; + dev->int_input_en[i] = 0; + adp5588_gpio_write(dev->client, GPIO_DIR1 + i, + dev->dir[i]); + mutex_unlock(&dev->lock); + } + + if (dev->int_lvl_cached[i] != dev->int_lvl[i]) { + dev->int_lvl_cached[i] = dev->int_lvl[i]; + adp5588_gpio_write(dev->client, GPIO_INT_LVL1 + i, + dev->int_lvl[i]); + } + if (dev->int_en[i] ^ dev->irq_mask[i]) { dev->int_en[i] = dev->irq_mask[i]; adp5588_gpio_write(dev->client, GPIO_INT_EN1 + i, dev->int_en[i]); } + } mutex_unlock(&dev->irq_lock); } @@ -221,9 +239,7 @@ static int adp5588_irq_set_type(struct i else return -EINVAL; - adp5588_gpio_direction_input(&dev->gpio_chip, gpio); - adp5588_gpio_write(dev->client, GPIO_INT_LVL1 + bank, - dev->int_lvl[bank]); + dev->int_input_en[bank] |= bit; return 0; }