Message ID | 20231225113524.8800-5-l.sanfilippo@kunbus.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-11017-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp347616dyb; Mon, 25 Dec 2023 03:37:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfUbox1cxQnCQgg6ZJmUVhYgs12NxX9UjIYnRcYbS2d10IYHk2+pFzbCq5FLH5m0NGN0bR X-Received: by 2002:a17:906:38d6:b0:a23:57f3:95a9 with SMTP id r22-20020a17090638d600b00a2357f395a9mr2591574ejd.2.1703504236824; Mon, 25 Dec 2023 03:37:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703504236; cv=pass; d=google.com; s=arc-20160816; b=RJCTKZS8lPJ7xqfd/Er0Yy1/NTCrQW7wKlz1PkGkBNcQlEMRtwBvDRzi1UV8Pdn7Hg RkkTJlLApi/QzJo6P7S/cveBTmru/dK+vOP69ggq4qfwzWLfMs9aL23IrXi2qZD6PIME urWiO6w8Vr7ApG5K0TrNlemdhjPvdrRlBmFbNMf2y8ED+CH1BTDzjToXNy8ELqPzeBeT 5Ilzy8ViCH2k0OYYt7cAonXOI3323ZzQOfsBn4cA2/sakOifsbt2wbK5NnFjlB6r4d9/ wT0PmHOImRepoiDfnAgzyPrZlZ2baQQs6xBtMmgSRc7Nu+sIcTBu09I30lmH/IB2O0C9 odRg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; fh=B2vyzCgBWMD+NZwvvpzOCCEHx/Ak8bOEWPEoN6LGloM=; b=h4HnwWBUuWgskzTPQGgFtiEu386VuXqnms+VWDG/dqbk3Gucq0zn84MJtfvAwTt/x2 v1no2CyruxAUx+LbwrWba2qofXRWeLstj5jz8zsgZ03rSnPOhhsd63FkY9++/CmpHjeX h1nUgkG2z08z/ZpKCOabfebyqWFA3hSDhdH0TxZ5phXSERkH47gHZbUxXfcp1dY4hGq3 /LKF4vaA+y/P9EXDd9qlgaT+cpdJHUaCJeTuA+UKdDhdTqzxXwVk1adR/zWgP1U+RPs5 rxloLTYMkHTSA5WnafPheClV05+Vi3xIVaQZ6TMuS5rUa1zJFumW9cmt7vXiIaV8kBnk lpDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=w1ji+nWt; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-11017-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11017-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c9-20020a1709060fc900b00a26eb9b2d62si1190319ejk.727.2023.12.25.03.37.16 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 03:37:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-11017-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kunbus.com header.s=selector1 header.b=w1ji+nWt; arc=pass (i=1 spf=pass spfdomain=kunbus.com dkim=pass dkdomain=kunbus.com dmarc=pass fromdomain=kunbus.com); spf=pass (google.com: domain of linux-kernel+bounces-11017-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-11017-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=kunbus.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3A8F91F2204E for <ouuuleilei@gmail.com>; Mon, 25 Dec 2023 11:37:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A66C52F98; Mon, 25 Dec 2023 11:36:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=kunbus.com header.i=@kunbus.com header.b="w1ji+nWt" X-Original-To: linux-kernel@vger.kernel.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2052.outbound.protection.outlook.com [40.107.7.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DED1F51C27; Mon, 25 Dec 2023 11:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kunbus.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kunbus.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uhgamo/qxh7U4Z+LczJ/SqVEWiWKp9PVxnvh7Bc8QErvHM/KD8X3PvpisX5PMntWfhiP1sG9yrEDnC3IHPc5Q7HgxywAeiY5Wwd3LFv6uuSf9ATLeVkKEg2cAawW6GasbB/ibJlOrHUJLwaUZE8NqxW+XCYFg6XiXwPqgvg7aAlE/9tNS5m5uhkLj/RZqOY++WSTlfV01DNTYjt/sA5IHzJj4d4iEk/1yDN1XMuRTwparwXmzQG37Hb1qv5juE1gnRSAskXvjxK37zWcjhRT6Zyvk5x+M9cmiGuaEaiFRjQ/D9s/KiHUsFUUhBZPp+hzxs1q8f3GOlQT0KEXtcpNVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; b=YEMr8QeaKZGTm8HbQlXVpdmzDBiXpH17KgOg5cBBGk0rBC6pEoBo0kSY8d8Gt0id4+MQvWMQiAE9qTK3Zq7EDB3MijfRSEfXIByCxZUfXwvy/ti4cK382w4iFdv2hPkHRa6FNtF/jcdhIBZQi7u9l7BkTcdofTI388g6HSktP3R3+xHUBEU/ym1JB2Iz/dKMl2ksupEFHTK4BzqQSvpqhSmO9bPIoPcadjUBWN90bZn4kwkjvXOiZLLbZmbjZtz7Y70D4k8QX6V38pjfAQKerPVgL4bsA/75302NW6KlQ/55oxsL7283ozp4+fdIjPV2BF3K8xiITm/+o5BOWLBcsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=kunbus.com; dmarc=pass action=none header.from=kunbus.com; dkim=pass header.d=kunbus.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kunbus.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ctoSUvaSE63QhX1RJ/Y+ZsAabtaxgzq3AnK1Gc9jmAU=; b=w1ji+nWtf5OJqGPjcOFRHCeTrVoPQ3mBx+y4OXM7oA0O5Ufk82I4g3cXqBuRACBN7DVPcUqjsRZ6pZrfDIobGGhksKh95DMDw7x3q1BXmRmK+3mKTS0MBxem6ULkoZ5dn9lct5YIXXDeb5ucQpIOx8SB04yKqgaQRvy0Qy3P5CM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=kunbus.com; Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) by AS8P193MB2061.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:44d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.26; Mon, 25 Dec 2023 11:35:55 +0000 Received: from VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06]) by VI1P193MB0413.EURP193.PROD.OUTLOOK.COM ([fe80::653f:d0f3:e7f6:8c06%5]) with mapi id 15.20.7113.026; Mon, 25 Dec 2023 11:35:55 +0000 From: Lino Sanfilippo <l.sanfilippo@kunbus.com> To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com Cc: u.kleine-koenig@pengutronix.de, shawnguo@kernel.org, s.hauer@pengutronix.de, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, cniedermaier@dh-electronics.com, hugo@hugovil.com, linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, LinoSanfilippo@gmx.de, lukas@wunner.de, p.rosenberger@kunbus.com, Lino Sanfilippo <l.sanfilippo@kunbus.com>, stable@vger.kernel.org Subject: [PATCH v6 4/7] serial: core: make sure RS485 cannot be enabled when it is not supported Date: Mon, 25 Dec 2023 12:35:20 +0100 Message-ID: <20231225113524.8800-5-l.sanfilippo@kunbus.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231225113524.8800-1-l.sanfilippo@kunbus.com> References: <20231225113524.8800-1-l.sanfilippo@kunbus.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64 X-ClientProxiedBy: FR5P281CA0055.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:f0::17) To VI1P193MB0413.EURP193.PROD.OUTLOOK.COM (2603:10a6:803:4e::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1P193MB0413:EE_|AS8P193MB2061:EE_ X-MS-Office365-Filtering-Correlation-Id: 25892f0c-64d6-4563-bcbf-08dc053da757 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dYRxqpEKapPguGhfz1jXmu2nZjVbz12ASsRhsva6mrhAblV5eZuvhRaB2wZ2B5sipOUJh0czw0Do8NVfAKDpJu71fB2qrJkjb7ypxUtcyMARfL2Vo7q0NFFifIhMmFEcTKqM+3uva2x8mDJjQNJuhh43zch4mj25s9VYZRYfUBIm5Kyb3wnJ6tuU31xXg89gaFX8K0/E8LUatxU/U6QfUMvew6is7hSw9SQH15coGbdpiAPKmsms+p5fxq3Vd8x3A3OIcfZpKLOok45NrNGmMdSNvjwAHJNAektupX9sx7l6B7yUfTG9DApfUEwUhVnkCtYC67DDTDfb3z+SwAjFwY2i4gvWGu4SoOhD1Z7Q8G2tkOMBgQMidrK/RFLnUBH0qUozGmRTvdsBS8M5CpHbzP5GrxtzInQW5fp8W80hgqd16uGew4i3R2EDdhKNinvG5U5MZTHzdmV+zBdz6yn9X5t7kCcWucpF5CVpHqySDF1s3ptQ7FfhsYU2RKsbwEFSnvhP+gvEqm1TD7bAHGV6/Qsg55k/btrfuZJ6ksr4NEeShvbCMjEyFYNlWSPR1WCv X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1P193MB0413.EURP193.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(396003)(39830400003)(366004)(346002)(136003)(376002)(230922051799003)(186009)(451199024)(1800799012)(64100799003)(2616005)(6666004)(6486002)(478600001)(2906002)(8676002)(8936002)(5660300002)(36756003)(7416002)(52116002)(6512007)(6506007)(66556008)(66476007)(4326008)(66946007)(316002)(66574015)(83380400001)(86362001)(1076003)(41300700001)(38100700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?Nq+lTjuMrl/0ERPmSiQXDa+o6JjX?= =?utf-8?q?Z63EQswZkM8YtWJBmu/wSxw+Te4C0pHHyFbyqHYcPtIQrEOi73fvWHdAWsVNTtrAF?= =?utf-8?q?1P2eSkqBiYFf5+qv3V+m53AVdCM4Kvv0GLBKy8xfpwPvciC/8oJ8KUos0567P+mx+?= =?utf-8?q?N+k6r3pRkAOJwV8yGO4452TcLZ/+MZR/FyDr0ZOvfKEqULrxWWH+hnzJRFGGboy4F?= =?utf-8?q?VxxO5yV7/mCfDr0DOULkFkIlMmNw96BJdI1qIPJkmYyItMZFCyPxy04CY+birqKr3?= =?utf-8?q?PclSwleHcGUiYl/rXXHSWzo3H5hhx8MAcqJJjja0DrHlCkioa0flpQwBpzAKVz7VM?= =?utf-8?q?KLtnWMsrEhmtHOIGLANYaHdD2azy7aoML/UmSNmXX4eGW56n0liY6mQ7Xl+HDrtnH?= =?utf-8?q?D5GQghTR/urisFYAiqAoBxZDyYUARFvYFZpSXYlgySf0rC6tJ43gIdzLAqqMfu+uH?= =?utf-8?q?5wddD8uVVm3oNiJhm8f5czacNysiRACZ65YBTV7QGmM9OZYVUt7MyLIwb1o4Rb2d6?= =?utf-8?q?Ixp/aUufcNLbJqi0Gb1gYuWSVMpGuGKn2yxU2C1NtU/U+J91zt3cMnzYQj1wj9iak?= =?utf-8?q?BIy73IBeeEX45Bg0pLrXHv6qd8r3GIoCQ6EMtWygdyir0pU9Qsq+QZHk3g4XaW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VkDI4hLD3b9fdfUt?= =?utf-8?q?s3KBAPK5rj46I5J6NiU+0KcSuFHk7QKKE4kI03OvZtKj+vKJV/rLGJo0U2ipXlg+/?= =?utf-8?q?7RWbr7ZU2Fr?= X-OriginatorOrg: kunbus.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25892f0c-64d6-4563-bcbf-08dc053da757 X-MS-Exchange-CrossTenant-AuthSource: VI1P193MB0413.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Dec 2023 11:35:53.9842 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: aaa4d814-e659-4b0a-9698-1c671f11520b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1QLWCILvtFq2cYHxzCXWSN4NIZeG86c6fn5TluajrhQJs1/vGnmwQoKr3rcknazHD830QXfUkLxApUYuw2KwlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P193MB2061 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786253658779754599 X-GMAIL-MSGID: 1786253658779754599 |
Series |
Fixes and improvements for RS485
|
|
Commit Message
Lino Sanfilippo
Dec. 25, 2023, 11:35 a.m. UTC
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. This has a small impact on userspace visibility but it is consistent with the -ENOTTY error for TIOCGRS485. Fixes: e849145e1fdd ("serial: ar933x: Fill in rs485_supported") Fixes: 55e18c6b6d42 ("serial: imx: Remove serial_rs485 sanitization") Cc: Shawn Guo <shawnguo@kernel.org> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: stable@vger.kernel.org Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Lino Sanfilippo <l.sanfilippo@kunbus.com> --- drivers/tty/serial/serial_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f67fb6a04983..28bcbc686c67 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -1469,7 +1469,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)))