Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp766221ybl; Wed, 4 Dec 2019 10:29:47 -0800 (PST) X-Google-Smtp-Source: APXvYqyoedXKqCc4KIkSkJPHBLWZmKLRRCgbtT+QVBUfBC8JXfjkfqrbdbCB2vyDXWXEcyaFuG0p X-Received: by 2002:a9d:7c83:: with SMTP id q3mr3600472otn.66.1575484187158; Wed, 04 Dec 2019 10:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575484187; cv=none; d=google.com; s=arc-20160816; b=E4KPW2sUe7P1twn137ZHkj1RzJAl2WruTI8z1IgqyeFoibz91QdHqLFHeKuVsa50zI W5QTIFosaO9NorPpnZuzOifD1XiJ/HR5jpiDHkfdxtFFUZlSsmGdM8+GppDsZc3Gj44A 6A2754PdMvkq4ws9TiVLPue0hqaJFpPFd+PDguqcjBN4y5dZcatbD7RYVxCIVIkcyztE GGBPfbzyRAu7c6Q49gPFSoRuC+vUu0ex7DFnalGBVicbfFnwSMadUDQvbKb2P85BUCeS EfmWbFOvyBHkrARBq12l+53eCqJ6lgEtHzCY12cKvOGGPEgkQCnwhlbPNbU/uGmMXZbt xpXg== 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=W2x4I2ObhOv79xBPc1DYc+1VKoK2kPldZeHeuLfyNU4=; b=DvbH5j3vCMmLP5aFnLeafMSjecyTbBtqHA+FJrfSf1eeerVDdFY6CpiotrQQ2eHIM0 644/ErXjYaP0azGF7WWEozKFEEh1S7JaXm09vgJQ/MwWMI9EXSrLPCbnReUg/CR9AcW8 Zl77fwDN5OKqs65nnkDBZFN0evpg95X1wqzMf/z2gjR3iyNaF1n9GNsqO5lRWfEP5Ndy RA57hHASo34vipH3wBO3xVVCFtI7LEuW0MTmfY3K7L4SUJ6F+K82B8LVZnU5t3K1GbFO unpY+bJT4oOSd2xStUt1AC4luduMYNfCqpESzvEYsHt5VZeG+oz5QjPtHvY49G8rF1sj 64yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ujZL07Cs; 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 u4si3797315oig.200.2019.12.04.10.29.34; Wed, 04 Dec 2019 10:29:47 -0800 (PST) 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=ujZL07Cs; 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 S1728620AbfLDR6M (ORCPT + 99 others); Wed, 4 Dec 2019 12:58:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:60430 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728564AbfLDR6K (ORCPT ); Wed, 4 Dec 2019 12:58:10 -0500 Received: from localhost (unknown [217.68.49.72]) (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 C93CD2073B; Wed, 4 Dec 2019 17:58:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482290; bh=qiar1VaVBvPmu92UC81QiJx1uqOjg2HjOpaJCa2CW2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ujZL07CsxXwNlqD/1UTJ8/EgmJHDkrVMG3actr0t7SfPSYyqNuVyIVaDaNa1bgw0w H7AVNmkOHdA/c4wDPk9Z8pIiTI243YD2cL+8tootjkYM2mOXIOqi5QZo3b4dp1rFj7 bnJB65DkxjiN2YuVyaJi8797jdjZNSWCzv2vKzlQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Kozlowski , Linus Walleij , Sasha Levin Subject: [PATCH 4.4 27/92] gpiolib: Fix return value of gpio_to_desc() stub if !GPIOLIB Date: Wed, 4 Dec 2019 18:49:27 +0100 Message-Id: <20191204174332.251335660@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204174327.215426506@linuxfoundation.org> References: <20191204174327.215426506@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: Krzysztof Kozlowski [ Upstream commit c5510b8dafce5f3f5a039c9b262ebcae0092c462 ] If CONFIG_GPOILIB is not set, the stub of gpio_to_desc() should return the same type of error as regular version: NULL. All the callers compare the return value of gpio_to_desc() against NULL, so returned ERR_PTR would be treated as non-error case leading to dereferencing of error value. Fixes: 79a9becda894 ("gpiolib: export descriptor-based GPIO interface") Signed-off-by: Krzysztof Kozlowski Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- include/linux/gpio/consumer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h index fb0fde686cb1f..4a9838feb0866 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -398,7 +398,7 @@ static inline int gpiod_to_irq(const struct gpio_desc *desc) static inline struct gpio_desc *gpio_to_desc(unsigned gpio) { - return ERR_PTR(-EINVAL); + return NULL; } static inline int desc_to_gpio(const struct gpio_desc *desc) -- 2.20.1