Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4004024rdh; Fri, 29 Sep 2023 08:29:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPJTASHaTRwedWdELff5CMMAOxb1Qv1KVEf0axnEB/9bSUjv1gzK06ALEKQBlYYhXunYVL X-Received: by 2002:a17:90b:1982:b0:279:dae:2d3f with SMTP id mv2-20020a17090b198200b002790dae2d3fmr7112049pjb.22.1696001371833; Fri, 29 Sep 2023 08:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696001371; cv=none; d=google.com; s=arc-20160816; b=HPxl74DgrfCBFFK4ML2wjAq2VCxaRWNPwuzIquS9mLiRmBgkp287OJigMEjQsG0a4S U2gnzG7m2q+fn0wiGI9IRw+yN2xoIZ2Oo0+tYbztaGuvszGtzWCspCzCP/uldTfIBocY GlfBpsBhUoIPF5Jr6W9BZIwivZ9P8bsvQqBBur8v4VBsimplhOPE2X5bMtJea9raQ1aR SIJjArw6MclvSAPv5vBA53Ja9mlf/p2p6bzTajFfsCg+Qi+GXk+4BA6GNMI839B/JPyq EGD7o+xmm5F8gZhyG1KHLsAjHEx/0fAeyHcsIUm+pY2JPu2TDWJmgXE1KdcnjjyKIcUg ie0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:content-transfer-encoding:mime-version :references:in-reply-to:message-id:cc:to:from:date:dkim-signature; bh=aPBodZxRvLV0np2WN3M801BRhcUVWxN10VLoZTjTjXY=; fh=/aZ9LewauAhUb1PsKQRjRzUcFNbxu5vJ1wMiXpZ7t+I=; b=wtYzlXlB4frj7/ISQxNvNi+aAJUizfp440JclHlgjvnkkIe9dA2a3taqew5VEfvtcg zEpU1I1WI7QGAignalTy6BV1CyGBWAAdOizT5vvbQTF3V2ZnbY8+srh7lSVFYXiyAPGp vE6g3ZOgCCbO6Xm2kO1yRkGOzJHv1r6kAdzvqxkgEiXKvkVesR5kEAOrKIa2hUC84byL y9Fqpt62JZfd9HmPCMJIjonwbaHDlMMiv5TLG5/F1v85/kpRDcst4oRuO7148J+PHNbL bQRbV7YdQaL9dzQVX0lZDQ0IezS3c67G3pW08VoHxbksZ7SU4BIJofNDdxVRUmSXGbvL XJmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=oKk9Tlrg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id x14-20020a17090a6b4e00b00263a99b8448si1706815pjl.113.2023.09.29.08.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:29:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@hugovil.com header.s=x header.b=oKk9Tlrg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 81DD38116E55; Fri, 29 Sep 2023 05:17:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233231AbjI2MRd (ORCPT + 99 others); Fri, 29 Sep 2023 08:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232964AbjI2MRc (ORCPT ); Fri, 29 Sep 2023 08:17:32 -0400 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E2A8195; Fri, 29 Sep 2023 05:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=x; h=Subject:Content-Transfer-Encoding:Mime-Version:Message-Id:Cc:To:From :Date:subject:date:message-id:reply-to; bh=aPBodZxRvLV0np2WN3M801BRhcUVWxN10VLoZTjTjXY=; b=oKk9Tlrg3Q0DHLupqtQSEq/wSY EISS1RabBeiZczqjv13RukBUcK4g/IgGNbfartgaf0MN46gfReo4pTnf51ErM9z/z9h8m/nx6/sRH Pe94ZTXMm/o835GuhNcUHCQ6etRaBuJ0p9VPNhusTsaQKZs1nuA08AB3L9ItbvMHOzHQ=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168]:52582 helo=pettiford) by mail.hugovil.com with esmtpa (Exim 4.92) (envelope-from ) id 1qmCQj-0001cn-8k; Fri, 29 Sep 2023 08:17:13 -0400 Date: Fri, 29 Sep 2023 08:17:12 -0400 From: Hugo Villeneuve To: Lino Sanfilippo Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de, ilpo.jarvinen@linux.intel.com, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, l.sanfilippo@kunbus.com, lukas@wunner.de, p.rosenberger@kunbus.com, stable@vger.kernel.org Message-Id: <20230929081712.7824dca40828ff873b3352ff@hugovil.com> In-Reply-To: <20230928221246.13689-6-LinoSanfilippo@gmx.de> References: <20230928221246.13689-1-LinoSanfilippo@gmx.de> <20230928221246.13689-6-LinoSanfilippo@gmx.de> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 70.80.174.168 X-SA-Exim-Mail-From: hugo@hugovil.com X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email X-Spam-Level: X-Spam-Status: No, score=-4.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Subject: Re: [PATCH 5/6] serial: core: make sure RS485 is cannot be enabled when it is not supported X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.hugovil.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 29 Sep 2023 05:17:41 -0700 (PDT) Hi, remove superfluous "is" after RS485 in patch title. Hugo. On Fri, 29 Sep 2023 00:12:45 +0200 Lino Sanfilippo wrote: > From: Lino Sanfilippo > > Some uart drivers specify a rs485_config() function and then decide later > to disable RS485 support for some reason (e.g. imx and ar933). > > In these cases userspace may be able to activate RS485 via TIOCSRS485 > nevertheless, since in uart_set_rs485_config() an existing rs485_config() > function indicates that RS485 is supported. > > Make sure that this is not longer possible by checking the uarts > rs485_supported.flags instead and bailing out if SER_RS485_ENABLED is not > set. > > Furthermore instead of returning an empty structure return -ENOTTY if the > RS485 configuration is requested via TIOCGRS485 but RS485 is not supported. > > Cc: stable@vger.kernel.org > Signed-off-by: Lino Sanfilippo > --- > drivers/tty/serial/serial_core.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c > index f4feebf8200f..dca09877fabc 100644 > --- a/drivers/tty/serial/serial_core.c > +++ b/drivers/tty/serial/serial_core.c > @@ -1432,6 +1432,9 @@ static int uart_get_rs485_config(struct uart_port *port, > unsigned long flags; > struct serial_rs485 aux; > > + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) > + return -ENOTTY; > + > spin_lock_irqsave(&port->lock, flags); > aux = port->rs485; > spin_unlock_irqrestore(&port->lock, flags); > @@ -1449,7 +1452,7 @@ static int uart_set_rs485_config(struct tty_struct *tty, struct uart_port *port, > int ret; > unsigned long flags; > > - if (!port->rs485_config) > + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) > return -ENOTTY; > > if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) > -- > 2.40.1 >