From patchwork Tue Jul 18 06:56:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sherry Sun X-Patchwork-Id: 704292 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 EC317EB64DA for ; Tue, 18 Jul 2023 06:58:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231499AbjGRG6U (ORCPT ); Tue, 18 Jul 2023 02:58:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231489AbjGRG6T (ORCPT ); Tue, 18 Jul 2023 02:58:19 -0400 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2084.outbound.protection.outlook.com [40.107.15.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D20171E; Mon, 17 Jul 2023 23:58:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ln37CPal0xS04z2LFZut5ejnd0EKProBwhXoUcpfCaQuzAw5cyAwP/y6ZHSYOjzuEuW3wcRQWa/5lSgDBcBgpTp+Szu8k2MGnAtEst56qk+7be8XD5U9gl4SoAr5sncsQNru2OsgBcnrSiNz4aV8z0Y9X8WqpYVtmoOigF6e/DVDGV23wwCnkTMjAaX3w2xUa3d3BVrKHMR3KbEjby3I0Quw8VRZjM9MiNhX6wVlTQwXaiQw8LI0z2XymYfUhcGFRd/Lh/udvoC88grpcK/2fE2f4FOodgYHwyVnx5D5W+1UwoTJn3seK580ng6vWj3r9kS+uBE+ykd41iRKJuEADg== 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=6XYZKYh5/XNOu60AoS46G4s0Jf036Mmq3C2oTqfNl90=; b=E1/w3ynZD90FFAvOQQkSDAox3r594zYZdnpWq6WXpwEe1qQ3+uHKp2CUYVBjxVWMNCAyH2+voJYtG59EzBPJR6u1YRZ8ulbhnqLDrRaLVW/InbEvU9uLP1STWF9NB+R8q+NvIri5j4u41Nxc1tJvyF4QDOy5lpXnnEVXjwIOhx2WNN/B9wYlZKjoRuCH/IVhdIeeDGCKilbzpF41CIcqqivY7eIXmaYEfcqXkGjzfY4R/OawTt7doqK1bQnYEYmHNfzDaVRqTY0etmwTuCQ9ZQIZC5hA9/FchxJ2w/oKY243DkXycfcnY5DAyNLRcKRHxNxEzpCb3ApDoo3W8YqzVg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6XYZKYh5/XNOu60AoS46G4s0Jf036Mmq3C2oTqfNl90=; b=iXt1XGUvHMophZ15t5ZKhCo55Gn1Wzogox/wwbRbF+M+vhX3apYHiRyrM3xqo2Ivux0/zNk+vONcTSdkvGIxXX1WVc9oJsBAqUqNXpxsW4ABXdyou9mx1x2ZIk/q+E4mDtp5McJS6rTBdw4q/PCxbhGYBcy5rCgvrXkKrPzxh7Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) by DB9PR04MB8203.eurprd04.prod.outlook.com (2603:10a6:10:242::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Tue, 18 Jul 2023 06:58:10 +0000 Received: from AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::c5e2:98f8:b03:2189]) by AS8PR04MB8404.eurprd04.prod.outlook.com ([fe80::c5e2:98f8:b03:2189%3]) with mapi id 15.20.6588.031; Tue, 18 Jul 2023 06:58:10 +0000 From: Sherry Sun To: gregkh@linuxfoundation.org, jirislaby@kernel.org, ilpo.jarvinen@linux.intel.com, shenwei.wang@nxp.com Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx@nxp.com Subject: [PATCH] tty: serial: fsl_lpuart: Fix possible integer overflow Date: Tue, 18 Jul 2023 14:56:45 +0800 Message-Id: <20230718065645.6588-1-sherry.sun@nxp.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: SI1PR02CA0016.apcprd02.prod.outlook.com (2603:1096:4:1f4::17) To AS8PR04MB8404.eurprd04.prod.outlook.com (2603:10a6:20b:3f8::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8PR04MB8404:EE_|DB9PR04MB8203:EE_ X-MS-Office365-Filtering-Correlation-Id: 0d3c5947-f3a4-401f-5b40-08db875c58aa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qQs8y0A8WaiY2Bgc/c6Pyk9M1KyrJ8TElkbldVDPuNtxHs1R1HpdZS6RFHa6FVXJ27k0MvGSbiMo/HtWBWHVeHoB6cDSgtjf7Eo7FEnMuY5ujeFr3asIlESqmAeU4JSDJDZycZ5/+OD5z0D7XuUjtxKi/QCc9PQOpQRFBoKpi0lq2OSoO5uvjWaCHKibLgT+OBUdHhHifjRIF0pU0MFwqAZs7Jg94yhNuG49M1ANMKS6lllC8dKCx3VvtwpIvJkw4b/e9nCFxAbKc71NMqnQs9UwBJ+JEzNUWlCJTQJ21EDZmJTrRO3d6zoa9fL1iwZBaYwjdtFYtepSwoPMYW9DX/lRzIMAHuyGpEDedw/fUBfipO8g7GqdHAiuQL14RYCOt6eW8eFebcCOJB5I7u9dSLNlMKQ3HYBNCPTOdFAc75WdmTiycghxJ/FbNdGsTbPR9KndJ/eqCgEmdtw4ME7QPKV89RSR1EkLb+VwCNXwNgLm3MQxpqXY3wjMs+mqbKPUy4mlZnzJxdSXtFuOdR2wVtqacYHDFm5uksVEU/xWDKOvp6PfA27UzKJJ2/mb1svy/0ucxk1vdAUb99Zq8QFdqye8bUwv6IABFq+VRXefhf2Zq2aeJcuVoSkh3tvxkiAX X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8PR04MB8404.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(366004)(396003)(346002)(39860400002)(376002)(136003)(451199021)(44832011)(478600001)(5660300002)(66556008)(66946007)(66476007)(4326008)(6636002)(316002)(8936002)(2906002)(8676002)(41300700001)(6666004)(6512007)(1076003)(26005)(6486002)(52116002)(6506007)(38100700002)(186003)(2616005)(83380400001)(36756003)(38350700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cy1IEM9kW5F/Yz0InWUaKVyYb1DodUjKYlnAuyiO1f6U/JmGBehwI4+snsjjhwoJQ4pKjQFG4OhjPG+5hY4s4QQdmucIdfj8OK1nRh3ECu0nNDoAo8oX6kngixPG7vRxL2HbmbMnuK7+HW3KZ5SjENH0A1Pmj0W14mHMgqinNsl+vr03Eb/smuq9HXDAwftBaNxO1jHsSZDUOXjbYAIDqdUVZv4BXit9KYis3rIrPRG13961juHiViTH9U1JABopbD0nDSciLLH1G7CMJ5u2IOqX8URs72TzO3dRJsI7BEUa7XIV5XPGvtFk9bOmMr86X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fKSU9eUV64Me9mFaAiws2xJ59AZyhRhcQxQKpX7In4FIymN6YAy35LKnjjTrGyS72uThi3WTiJjkZ2byb5YFt6eWaEwBLgTvXh7NtMzsJOitS2N2Jt2MyMkf6qLEIFhD75Zjj/bIAah6A1D3YJf/Rx10iH3FDv/HDGpgfISpZl9eDoL7UcpFLNb0yibFFqWZE X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d3c5947-f3a4-401f-5b40-08db875c58aa X-MS-Exchange-CrossTenant-AuthSource: AS8PR04MB8404.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2023 06:58:10.3794 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 6I0BslkB0y19lT+LAy3AIC1QbdOI2ArG0yOT0n6WRciRkVwvpbqwkeW7EHjr81k6/QAR3e/iRrNuh/No4vgWaQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8203 Precedence: bulk List-ID: X-Mailing-List: linux-serial@vger.kernel.org This patch addresses the following Coverity report, fix it by casting sport->port.frame_time to type u64. CID 32305660: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN) Potentially overflowing expression sport->port.frame_time * 8U with type unsigned int (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type u64 (64 bits, unsigned). Fixes: cf9aa72d2f91 ("tty: serial: fsl_lpuart: optimize the timer based EOP logic") Signed-off-by: Sherry Sun --- drivers/tty/serial/fsl_lpuart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index c1980ea52666..07b3b26732db 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c @@ -1373,7 +1373,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport) sport->last_residue = 0; sport->dma_rx_timeout = max(nsecs_to_jiffies( - sport->port.frame_time * DMA_RX_IDLE_CHARS), 1UL); + (u64)sport->port.frame_time * DMA_RX_IDLE_CHARS), 1UL); ring->buf = kzalloc(sport->rx_dma_rng_buf_len, GFP_ATOMIC); if (!ring->buf)