Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4559905pja; Thu, 21 Nov 2019 21:52:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyxJga+jGO38At6yOC9+DrH2XXlUeW8nr8lRThT56+2Qd4NU4BrUW7aVBFs4BnKiEuJhwa+ X-Received: by 2002:a17:906:7e41:: with SMTP id z1mr19504211ejr.63.1574401941992; Thu, 21 Nov 2019 21:52:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574401941; cv=none; d=google.com; s=arc-20160816; b=HDqmWLJe4er5F7VbtAWJ9J68B+vltSoA1/lP0/G36KjY3aGtjWgjbEPq9jP/IvoJpa gXG9cwud9oE0XnGzeyJm0sQXBy1VGq2ySkXETM1JRmpyKV+j3czqKVY6H1GJEXFkDQuL epFn74ubqSUAkj2rGiFRez7KYlclMndXeWCaormkAt7oNCBxFwBPeLUUiQZHwefXfCzI Fv+dzYZdi/s/VrxW9k+B1s0QZ0oALNx08ebA4KB9qWB9KR/J9ACyZhtxhfUuIKrhMkvo kufHQQn6qPShsoXYlTi3FR95gO82LTTUF7otdyoXtuqaacjmV+KhfWsEL+WLz0q0fkIa 3gWg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ThAqVhWrKhRQ0MT4s63Cnlosx/JkA7sGp+HdO1x68sk=; b=whfTXb4XKdyhPL3xHCJDjYkBXu1Oj8kYB8wX521TKtfhW8anPvqjP4D/1p2dS7IVby 2ZJl6FeLzauaAbJoHW/KL+1ixivIBaAC9NLx6QJ7ORez4fx88xIxd/HL61NmTW/R30n6 gV/WFC1Ct0ADzF0jjq/K3yL4PoRzvZAk9NdBtaQWsu7TLMCbLFDcxKoP7aYiaRQ3lWdX 77er8d2i/OzMGHk2UmS2CZyDIeWG8a0KU2k0+NPunzjl0ekIgGN/zlBaBgW/hNWsMZ0f BtsxpugLH4E1loHwVf37NMhIe1V4aieWBkyLTuJwm5C+b5zDFSMldgISc1hBfmxZ97Po 6RJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="1/RXbXFy"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si3292396ejj.70.2019.11.21.21.51.58; Thu, 21 Nov 2019 21:52:21 -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="1/RXbXFy"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727640AbfKVFuW (ORCPT + 99 others); Fri, 22 Nov 2019 00:50:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:54872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727629AbfKVFuV (ORCPT ); Fri, 22 Nov 2019 00:50:21 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C2D22070E; Fri, 22 Nov 2019 05:50:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401820; bh=oRalRQLcvw3mDLy4hoii35OLsY/POsYuwsyEtYJ06wQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1/RXbXFyudwcVDMaHlK8f3+Y8RFaNLrIdjEv1N5oQGE9WoaQQV3W0doXzHMkkner6 e4MhI+2CINsd6+TuUOozK3gZuR4Hw+yagQslWRLz7FwUcQTFv3ukeFj8plOHyAYlBc H34vC1unDNz2GPHJTFJ6VqeiSuURM/VM16DK4uuo= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Krzysztof Kozlowski , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 064/219] gpiolib: Fix return value of gpio_to_desc() stub if !GPIOLIB Date: Fri, 22 Nov 2019 00:46:36 -0500 Message-Id: <20191122054911.1750-57-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 412098b24f58b..8dfd8300d9c31 100644 --- a/include/linux/gpio/consumer.h +++ b/include/linux/gpio/consumer.h @@ -475,7 +475,7 @@ static inline int gpiod_set_consumer_name(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