From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 55EECC2BC73 for ; Wed, 4 Dec 2019 18:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 21C6F205F4 for ; Wed, 4 Dec 2019 18:27:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575484076; bh=qiar1VaVBvPmu92UC81QiJx1uqOjg2HjOpaJCa2CW2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zssd6dmdw7bAx7Xkb0XpEcSWGhyoKnJ3WITN4GA1Vw6K4jxQgdJC1aLC4xHJDV1nb QVr+1An1GysrDMeGn5wQZ1tAKak7cmxf4dIKeaqOrL1zEVyJiQZFoxkuqVhWeaaLz2 3YCydCRZyHZ7NfROeNn/YuGnUJn+mZ62NQEEtiaw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728626AbfLDR6M (ORCPT ); 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