Received: by 10.213.65.68 with SMTP id h4csp483584imn; Fri, 16 Mar 2018 09:07:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELth2M0j+57LSEvNigQHKTFAurUO/a7bwKJZFPtDJjjjR8Q8eJRLptDu/9oyCM/jB7BnqfEg X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr2728120plp.228.1521216443358; Fri, 16 Mar 2018 09:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521216443; cv=none; d=google.com; s=arc-20160816; b=MYZz9Ldnnpscyn5M5saiXrwmWmfJyNhDJJAf7RGkdB90ahRXlOGlzmZRDwxlhf51Fx j/NTMkPJgZ+16xn04Nq9aBNl4HQlh7RA6sWy+0vhq/Xe2RL0gylPEhTI9EDzYDPaLy2u 2spXs3G3h4X47rBqzyUzAN5sk//una/1+gOgbkCZ5Odme9ZEkZKgqPjROf5UCraPkIpq FnsBam/Ya7WsqShrZC3mUbEu6yf2Bjs6+O5P/0Vob0Ft5xrFTft4/DYLYij5uWNgE3Cr GheDko9IPM9gl+McZb8sJljj7u0b5I4PwC6MDvFyUY13gVCHymVorUguDjyC7r8AMN+2 PuZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nEwOaEWR0FM44Rf9nULHQNhcmtHtH1bqRrgo5V3/A0c=; b=ZmmcIPZ7wmetgwjLyGbDVR6cBHeOd/VTV/4jXR0Yig6/Xku3f+hO6dVc8Cf4Sd2uLC 1ieZNJq7FAWnDKcpyCrHfmW7R6e8X0pQx6E7tkQsHc3YIANRSFCzLMVbvQQo9oPxjy9R tY+MF/Dv7Xd8q7+nmDW+9gfSfJzjNy2Me0E0/CLQUCPpz/u22KV2tESermDo+QJaQ5Eb gLBLFSAkjX1LgamVVPn4a/8R8mqMiIxthhsFh2l0YxvIW4xufVMybFymRJaQhUEzdWOu Nl2VxoIlG35RKA3jQG7bG1eSUEifODZGNd3/YPFUw73nvhRAmo7WQiqvWoo+Z8ol9iB0 1hNQ== ARC-Authentication-Results: i=1; mx.google.com; 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 s3-v6si6347327plb.4.2018.03.16.09.07.09; Fri, 16 Mar 2018 09:07:23 -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; 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 S1754779AbeCPPlr (ORCPT + 99 others); Fri, 16 Mar 2018 11:41:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:44104 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754641AbeCPPln (ORCPT ); Fri, 16 Mar 2018 11:41:43 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2080FF87; Fri, 16 Mar 2018 15:41:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Walleij , Bartosz Golaszewski , Sasha Levin Subject: [PATCH 4.15 058/128] gpiolib: dont allow OPEN_DRAIN & OPEN_SOURCE flags simultaneously Date: Fri, 16 Mar 2018 16:23:19 +0100 Message-Id: <20180316152339.713629484@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180316152336.199007505@linuxfoundation.org> References: <20180316152336.199007505@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski [ Upstream commit 588fc3bceaf81bbd62e18af6f7bd475e01c2b7e8 ] Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If the hardware actually supports enabling both at the same time the electrical result would be disastrous. Suggested-by: Linus Walleij Signed-off-by: Bartosz Golaszewski Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -460,6 +460,15 @@ static int linehandle_create(struct gpio if (lflags & ~GPIOHANDLE_REQUEST_VALID_FLAGS) return -EINVAL; + /* + * Do not allow OPEN_SOURCE & OPEN_DRAIN flags in a single request. If + * the hardware actually supports enabling both at the same time the + * electrical result would be disastrous. + */ + if ((lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) && + (lflags & GPIOHANDLE_REQUEST_OPEN_SOURCE)) + return -EINVAL; + /* OPEN_DRAIN and OPEN_SOURCE flags only make sense for output mode. */ if (!(lflags & GPIOHANDLE_REQUEST_OUTPUT) && ((lflags & GPIOHANDLE_REQUEST_OPEN_DRAIN) ||