From patchwork Wed Apr 26 04:50:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Li X-Patchwork-Id: 677609 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C020C77B78 for ; Wed, 26 Apr 2023 04:50:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229537AbjDZEuN (ORCPT ); Wed, 26 Apr 2023 00:50:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239026AbjDZEuL (ORCPT ); Wed, 26 Apr 2023 00:50:11 -0400 Received: from AUS01-ME3-obe.outbound.protection.outlook.com (mail-me3aus01on2135.outbound.protection.outlook.com [40.107.108.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D0A31B6 for ; Tue, 25 Apr 2023 21:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4aMMWuvosIeOszjTKUXk1BCH+sH/NFKkvnQMRstzN4UA3upiPUuMADhI4k+8XnDlCiZxumSDdYKpfHEnclX7nqwfKS7KvkFsgemgbXpJHu/PKedadf40uM6knoH74hE4xq22bdW17DY0RXw9biJ6lbj/ghDY1aiYRo5YgiXAWZPP4UHzRkpQFI+e0JE5shePUUz7lvstxEiD32s0jg8pq/LF2Z9LcUjKUjuYZA5tvBTRAYdUAAYyAm7Jnptm8rrkOtN5klnmVxMwwDHGvWOK66FxJDGn7wpGYQBeykfhl6fnrsoQ/z7kDFz36uu9s66SDbv8RcqQhzjWsb3rSkHfg== 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=91S+iXNhBvpKwaBwj7Icx0MfOYY34EUDcxOr8d+ZKQc=; b=AO0Ee51NlUotvN2sxG2cPAMS/6/OERLEvIEBihGPKwe9AturAdR/kejmWlr4izqtz640oUPSxK7rLvJZ6r5832Xdk7FAlmr1YnK4Ubs7W8ZyWnvYKImj7oq9ThooSLSSXSrzsYePj/ye+pkmDZ3sgSaITyUwA3qKJwjm3iMwMXZ/iIAHfd8EyxCfBkGZTCAVlsN+9eByyIEoDNoVanMToPvp03BpC/OSRlcGcflbtXvRn6Lo9l7/Kz5rq/mlsx7OWF6J6+/UUrqbAX5RM8Vbwzv2D/uIb+vMdXA1gtFPIx9tjeetIeODR7AdVHsQZbmS4yfRktUwSZANyUj2xwfLtQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=rfi.com.au; dmarc=pass action=none header.from=rfi.com.au; dkim=pass header.d=rfi.com.au; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfi.com.au; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=91S+iXNhBvpKwaBwj7Icx0MfOYY34EUDcxOr8d+ZKQc=; b=GNP+u0wepCQGPFk6cLA+KgE8oAPADOLyDK0W+ze79WbNGcQB6qVEi8qStu1IR5nRWff6duTY1HtVfKC1lrVnQiJqmf5eUaUPr8Nb7fgQjvdZKadBdJTvia9Viv0bbWpQ4cXNbKG6KTDiKXk1wqP9bGhq6sdSCTtIv5sHXjl8QdU= Received: from MEAPR01MB4231.ausprd01.prod.outlook.com (2603:10c6:220:12::18) by SY4PR01MB5964.ausprd01.prod.outlook.com (2603:10c6:10:f5::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.20; Wed, 26 Apr 2023 04:50:06 +0000 Received: from MEAPR01MB4231.ausprd01.prod.outlook.com ([fe80::c561:8607:c40e:1560]) by MEAPR01MB4231.ausprd01.prod.outlook.com ([fe80::c561:8607:c40e:1560%7]) with mapi id 15.20.6340.020; Wed, 26 Apr 2023 04:50:06 +0000 From: Ping Li To: "linux-gpio@vger.kernel.org" Subject: [PATCH] drivers/mux: Fix comparison of signed and unsigned integers in adgs1408.c Thread-Topic: [PATCH] drivers/mux: Fix comparison of signed and unsigned integers in adgs1408.c Thread-Index: AQHZd/o2t+VWHa320UyP0lqhjakknQ== Date: Wed, 26 Apr 2023 04:50:06 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=rfi.com.au; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MEAPR01MB4231:EE_|SY4PR01MB5964:EE_ x-ms-office365-filtering-correlation-id: 15ede90e-2ad2-4e57-fc63-08db4611b4a2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: pkFtnKpj9MslkNA9N22ndVP3hRhZnEYYKQRzfpwJJG5WAity5yTU5qqmcfYQitCVu1hcgBerUIE5DhUXqrJiZvBVBh8EK/OJgkW1totPgVEZKTrkemxSv+9MdkKcV0+n9GZpcC82EWsktsSpP4rJX9N/7x/KwX3olQaIUYZv4gvhwVOug78Zy+x+OshYzgb/lDAdbiob5b7QaXPuttMKN+iWfG4K9z4GNktDCiR/tViB4uG70W6ixkZbSX+n5fwyOsc65esAqFOAzcCevgBMYp1V+7aj4pnrcvRJ1npYL+defeA+3ncxxjGpDQ/KMJNb2KR2pPCBhCFwSnlvIHSSbBKtxQsxzzV2uP7xTSsUWVyhliPf73TzxY5McJODIFfQgxn/gyDSisY7exd2CJN8QvEkUqGvHl7drU72o0HxTyk7ubtiqB1EoWzd1RJIHG2xSbMaTdTfjLA4Ba1G/jRlQCRN+b61B1FkQM7c0bPPG9ASqG/YK1xeuejlrzo6tyMHtohmZB9MQeb+51GxCdIfdxAGYgKkOG7/xCwC6Zmid2Wc5ft0oqV/VYMf1Q5bsrMuxT/UAy++Q/jxh0WWaFuaPH94GiPBgEEYnTXvYv0vxb0= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MEAPR01MB4231.ausprd01.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39850400004)(376002)(346002)(396003)(366004)(136003)(451199021)(38070700005)(2906002)(38100700002)(52536014)(5660300002)(8936002)(8676002)(55016003)(86362001)(33656002)(7696005)(71200400001)(966005)(26005)(6506007)(478600001)(83380400001)(9686003)(186003)(99936003)(316002)(6916009)(66446008)(122000001)(66556008)(64756008)(66476007)(41300700001)(66946007)(76116006); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?n/RNOgfntMg+juN9P4PIZODnmk2i?= =?utf-8?q?/ql8VqjtVmbJWEt5OcsndJ9j6LVGYacW+UDlnlfNTlqreV9/8pfZM3I8+wZRHaytR?= =?utf-8?q?qCO+AJ4Xj432ZvsNzQ7hrQPB2X+7WlUHSQFcfhWvD0ubYOyzuJCnZKSxLdw0j1aKj?= =?utf-8?q?SRlff+EtKD5HoSxgLKWC/aftn+4PvbxZKox3qy4lzE9MWzFokiAzCY37cpZ89kz8t?= =?utf-8?q?owya5K72JZXtEjftfQeiUvdi8zwtHJa4pB2tWDFRce8vgLn26z6pUTO0KqoKYla/l?= =?utf-8?q?fk2AjXLXpn+CKEs1TMOsBGU2037ZHk0NCMSy9Q1ITH8bDl2YD86jrPZGUuiwoakl/?= =?utf-8?q?pGYt/bJCbXkr7vTfZH+hOj380iqg3c4Kmwid1aHS4Up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J/udAHgkPCP4ZteHqXpq?= =?utf-8?q?9Md4Hj0Q/ETscGV8qS0yKffx8b7uRzhY4FC9OlcD1IZELt47faX1Mck9nnH6fM4xz?= =?utf-8?q?cFE/KrU1XNqswkDHWxtO2HvurV9C3GX2Rlj5BArjBi5cvmc9B1s4YZWw7JdLvNf+V?= =?utf-8?q?UzM3ZK2SP7dfNC21ZHa3g5SP7s/ClqklOpQ4eM3/Gj3Qkhv89KtA+lB9H7Zf5UEjB?= =?utf-8?q?cyknPYoqtUfrDcdScAdqc/tcHVDuLyyDOj68JLddRqwq4yVsOXMv8F28=3D?= MIME-Version: 1.0 X-OriginatorOrg: rfi.com.au X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MEAPR01MB4231.ausprd01.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 15ede90e-2ad2-4e57-fc63-08db4611b4a2 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Apr 2023 04:50:06.2014 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0cbc6b29-eac2-4138-b37e-56a1535c99c3 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Pb24/m6typDq1MWV8JnzSqRbwxDwKy749OaWjoOBBGtXg2/dN5IieqiZP9tV0e+u2N5BNmBECpHpSpWs1WrnaA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SY4PR01MB5964 Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Hello, I found a bug in the drivers/mux/adgs1408.c driver that causes MUX_IDLE_AS_IS mode does not work at all. Specifically, the comparison "if (idle_state < mux->states)" in the switch statement fails due to Usual arithmetic conversions if idle_state is set to a negative value, such as MUX_IDLE_AS_IS (-1). Refer to The C standard (ISO/IEC 9899:2011), section 6.3.1.8 Usual arithmetic conversions https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf#page=52. To fix this issue, I suggest adding an explicit type cast to the comparison. Here's the modified code: >From e96bb5ab8b5c7e1dcda4ffeffc64d6b120579baf Mon Sep 17 00:00:00 2001 From: "Ping.Li" Date: Wed, 26 Apr 2023 13:52:53 +0930 Subject: [PATCH] Fix comparison of signed and unsigned integers in adgs1408.c Signed-off-by: Ping.Li --- drivers/mux/adgs1408.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/mux/adgs1408.c b/drivers/mux/adgs1408.c index 22ed051eb1a4..c59e0bed80d1 100644 --- a/drivers/mux/adgs1408.c +++ b/drivers/mux/adgs1408.c @@ -89,7 +89,9 @@ static int adgs1408_probe(struct spi_device *spi) case MUX_IDLE_AS_IS: case 0 ... 7: /* adgs1409 supports only 4 states */ - if (idle_state < mux->states) { + /* the idle_state will be implicitly converted to an unsigned int in + the comparison, which will fail the comparison if without (int) */ + if (idle_state < (int)mux->states) { mux->idle_state = idle_state; break; } -- 2.25.1