From patchwork Thu Dec 14 16:29:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13493238 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=wolfvision.net header.i=@wolfvision.net header.b="JnHWoiou" Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2082.outbound.protection.outlook.com [40.107.8.82]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A238711B; Thu, 14 Dec 2023 08:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IBxfwrf2kSaIMs1tDY5FPf7vKoF+hStGGxJKfSJuQ+jfvS9DrzRYoiI1Ejsv6lzcT0r50WxTZ7BNGvEDLTSIXPj7fGZgxHnmSQSfnRi5LLonz0neZwnEWr4xe2ZnTf3fFDrOnWab1BTs5+1xtqAxzrbXaecmzKZS9RCcV91WO3TzRhJG1KrgCAUEcFKpBWTsmixvKB9kW9ynQpJRHFkGtAKmjCv+MKIm6yHKabsoAgiDGRJr0HgTwwxbTZjTYp0biBruI1QgVeULGRn5xjn75ak1Nr8zg9bHExcnorR8QXnrayvnKuNpdKl+fE9xSGTyxX4z19O4Y9FHenCVk89ZXQ== 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=9Nbp7KXbUxxTU41IvOZEP4Y+wSOIC/dVuJsy2ah9s2E=; b=mh55u7loVLpSV3fwpXguWeANLhyTQqh4kEmBq4/D1hC2gPEQGYXkwJm2Wq17ccFOTeChE5xWz6OpU5EN+BVbuMsCAoKyDWtlmiZiGadDCriP1nt61MGP1Pl0W/FzjOK8gE7nhZe667270HGA9/dKEs6DwGidD/QpJabXeN46NyRltawUrv7mliPJidJUV3iv9I6Ymaa29dbut3jb99TmDvm+vjQSYrJIBmbGRcUrHDSl/8QZILHIqsNiqfXcal36CSd5kWGkfs8u5mljRzl3OjESmFBe18pfRVaJ7rygIfB0r3Yh2W0GwgW8Ffkq5oqd6Kl3p5e+78JYbrwNbW5uPA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9Nbp7KXbUxxTU41IvOZEP4Y+wSOIC/dVuJsy2ah9s2E=; b=JnHWoiou5Mz1J3nn7mkUlKYX4JzWE2NFfbZtSxUBExTeJq34cjwtDj9EH85FnNv9ezPzEZsuc3WPiLF2175Ndm2us7ZNOSNi2XxVyhSdW7lLNRzEQRGEESMYjpSX9hGGOs6ErgMyWllpsQvU7l6DDGGFEHVm4D9ehY4fL5FzfmU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) by DU0PR08MB8302.eurprd08.prod.outlook.com (2603:10a6:10:40e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.28; Thu, 14 Dec 2023 16:29:16 +0000 Received: from VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6b40:1e6f:7c94:71dc]) by VE1PR08MB4974.eurprd08.prod.outlook.com ([fe80::6b40:1e6f:7c94:71dc%4]) with mapi id 15.20.7091.028; Thu, 14 Dec 2023 16:29:16 +0000 From: Javier Carrasco Date: Thu, 14 Dec 2023 17:29:11 +0100 Subject: [PATCH v2 3/4] usb: typec: tipd: declare in_data in as const in exec_cmd functions Message-Id: <20231207-tps6598x_update-v2-3-f3cfcde6d890@wolfvision.net> References: <20231207-tps6598x_update-v2-0-f3cfcde6d890@wolfvision.net> In-Reply-To: <20231207-tps6598x_update-v2-0-f3cfcde6d890@wolfvision.net> To: Heikki Krogerus , Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.12.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702571354; l=1739; i=javier.carrasco@wolfvision.net; s=20230509; h=from:subject:message-id; bh=G8jD1YMhqm/GwQuFi+8ybk99Xtsx5Enpb51VaGZhocc=; b=ks125/rMHj9MP/oDOQ4RVolGqp+bBk2Gkt+jrvOZVYLyCbSkJHD7Gb3/E0eKr0pn0JiU7q74K v/jlWNtyGo+AR8PYew9gYCxv+K9zuJwMguB2WJ0bHhHoI1TgCZKEQQE X-Developer-Key: i=javier.carrasco@wolfvision.net; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= X-ClientProxiedBy: VI1P191CA0011.EURP191.PROD.OUTLOOK.COM (2603:10a6:800:1ba::19) To VE1PR08MB4974.eurprd08.prod.outlook.com (2603:10a6:803:111::15) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR08MB4974:EE_|DU0PR08MB8302:EE_ X-MS-Office365-Filtering-Correlation-Id: d396dd6f-1995-445e-708a-08dbfcc1d0e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YOkrW8J1in8njbgWfVLXutUWGWql1LPL4gF7a7fcDGDUWOYvuz0Sfjwm2sKG6GwqNQzp98WAbFZ0rT5xr+8uBtc8eGwzKgWBGdYDazhjFJXj4AOaTRS3okZ7V5O4EerYy1t/Vmk96Ef4SE+OrED9W5rjtsZofXXVriYAmjPhoRy+QDeNA+mgkqZEYVFnbVqPoAejc3qrNJ8H6fBg5fRatf9XAunLD2iaGNTjgqbeVDbPHpAei7WcaJIiKlkCnVsjcjMlpEfTFvPhrKi9Mx2RMjk3T00B2Y83DvUyi0g0DuXobTLMrkT0s3KvFooPxBYciscjTHQAJGMR1lLugnK/msLYKI4fJhENJPYin9KGQEDZgSmgGc9o1anoUuOltJq5lntgYHCc1Zf9D3Ax/cmWR0T/O+x//cgX2L9f6iiRFzna7+1qbkBnkrsk1J3mXpFZusi7+N63n4ma72WrJ1kqsetvt+ztl4kzeWYT6ZDjpxqscozIg0S64qfWNJYMNnkefvrgJ/747hPbyHNT3pgG2hTRmQiwjgIEVxK0GSxVvMLKrTezGqR5QZ7/gjWEzhEVwRgf82Q6IDP+UcZmt3fUOsw9uhVJ+16S9aS6XjcZNNVkC6vCzpxdZTMGZE6Ev2UF X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VE1PR08MB4974.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(39850400004)(376002)(366004)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(52116002)(107886003)(2616005)(26005)(6666004)(6512007)(6506007)(66556008)(83380400001)(44832011)(2906002)(5660300002)(41300700001)(6486002)(478600001)(66946007)(8936002)(4326008)(66476007)(316002)(110136005)(8676002)(38350700005)(86362001)(38100700002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RNjJTsxJR+POr/6/0ME+0vNGBUU+?= =?utf-8?q?qrJlnYsFX3ieM3r6Q7CTtB11eSLdzEWskPK7QFePtzk3O0GXb5XoU7XOIF04PXA7U?= =?utf-8?q?36qPIA2muPbpFxfhYqwl8N18w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7LrhPYv8roMmG6XYMY5RFNHkZAJLRg7hwFgryINrK8Il?= =?utf-8?q?w6Ya7gVZnNClfJtqBknHHLxLM0pabaruG1htZnvTdHnUr6vuHfmpu7vJ998/ScCa+?= =?utf-8?q?zxgvpjT1SH8DelD+FxgEsVRaOksiGRuZpcVc5pbRstwJcIgeDU3wzdn6QwLnOVg7M?= =?utf-8?q?8V6Pwfs4g6ut0usOfwv+FCZpy7hD0AnGIaIs4Zjkel7SpHwV++nY+dCVp09p4hhPm?= =?utf-8?q?MQe1/C5GpNaNSQWRj8bvpDSn2FzsjaYaKns5GS4z/G6V2MHb7ZJx8H9qrR6DnVPvL?= =?utf-8?q?MTiDz99vmF70VgOvF31RKf2wmBwaDjwldm47ZZxkfe8v21XD0wLHB2Df56RipeSO9?= =?utf-8?q?WoVK0+FCGQ36cNVFTnvt17EpeEOcpW4AC+XBn/OzSOmgAMiBlrF+BVTXzGc47j0g1?= =?utf-8?q?sYr6JNo7iSZjZCDRqrSuweEi2htMnANlO7PSn54KK6CMJCuz4QGAVnRNgWF6a47HN?= =?utf-8?q?z3SOWhUp0k/zQ3JfizXcmwS/R4Us+RUs4L6aBqfZD/lbmUGw9naTRA6vZXLxoips0?= =?utf-8?q?wFADzcizdZKh1NapRXMPcY9KEtazBLshhjeJpHXGrjIXEHCZPAGasBo=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: d396dd6f-1995-445e-708a-08dbfcc1d0e3 X-MS-Exchange-CrossTenant-AuthSource: VE1PR08MB4974.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2023 16:29:16.7878 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8gAqaoFCD69lPL89BonTnrsUDM8zLav8QsjB347qJzPG9N8iqnnyZfbF4u+A5y3wW1I9EOMrxufWmj/0QdYF+UwJW6x5Rr5d8yErbvi6dcc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8302 The input data passed to execute commands with tps6598x_exec_cmd() is not supposed to be modified by the function. Moreover, this data is passed to tps6598x_exec_cmd_tmo() and finally to tps6598x_block_write(), which expects a const pointer. The current implementation does not produce any bugs, but it discards const qualifiers from the pointers passed as arguments. This leads to compile issues if 'discarded-qualifiers' is active and a const pointer is passed to the function, which is the case if data from a firmware structure is passed to execute update commands. Adding the const modifier to in_data prevents such issues and provides code consistency. Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus --- drivers/usb/typec/tipd/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c index 83e5eeecdf5c..7f4bbc0629b0 100644 --- a/drivers/usb/typec/tipd/core.c +++ b/drivers/usb/typec/tipd/core.c @@ -330,7 +330,7 @@ static void tps6598x_disconnect(struct tps6598x *tps, u32 status) } static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, - size_t in_len, u8 *in_data, + size_t in_len, const u8 *in_data, size_t out_len, u8 *out_data, u32 cmd_timeout_ms, u32 res_delay_ms) { @@ -396,7 +396,7 @@ static int tps6598x_exec_cmd_tmo(struct tps6598x *tps, const char *cmd, } static int tps6598x_exec_cmd(struct tps6598x *tps, const char *cmd, - size_t in_len, u8 *in_data, + size_t in_len, const u8 *in_data, size_t out_len, u8 *out_data) { return tps6598x_exec_cmd_tmo(tps, cmd, in_len, in_data,