From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6820FC433DB for ; Tue, 2 Feb 2021 11:38:22 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E7C8764E34 for ; Tue, 2 Feb 2021 11:38:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7C8764E34 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=microchip.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=driverdev-devel-bounces@linuxdriverproject.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id B593920016; Tue, 2 Feb 2021 11:38:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zFZYsUo8Rwj0; Tue, 2 Feb 2021 11:38:21 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 0A54D2046B; Tue, 2 Feb 2021 11:38:21 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id CD6A71BF865 for ; Tue, 2 Feb 2021 11:38:19 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 269FD221DC for ; Tue, 2 Feb 2021 11:38:19 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1ui2bFxq0DPf for ; Tue, 2 Feb 2021 11:38:17 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by silver.osuosl.org (Postfix) with ESMTPS id 3C5FA20510 for ; Tue, 2 Feb 2021 11:38:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1612265897; x=1643801897; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Jzu8ew+tJ7XjQ0/QPEEHBA4QDypasGGIc5HXzOaJ09A=; b=b5ky9hSraeaSw00QkNtZUeTtZyjK8cqTNuQd62/mbnmm7TOxw0YAxL4D DsjjjQnHU5YPs4EHF5v5xxONsj1X+/cL3X0XZdHSLuIhq0YnTvKUuxRwp WOyXROUzqWBdf+MtbIXcMWQ09+GfmNINHuRumzEygaTHfzde8MOkqj2EO sgHFJFv3/LRZGBoepazswstzvbW4BnTlKnID8ulyV07Gp72CzbpUX5aZM WSDinnTPGpZ/t92io8Sy3kiae6vZtmeFVwtOE8LdaTNSecsD87q04P5AP xxr9RZtJ9fY23MaZifFNVMdaPsNNfUWlcIfc4udc3MWwjGqeQIybdZXSk g==; IronPort-SDR: egXNsETcaS4OE+xF5oAoIzYzMZCB7VfXMOeQ/3dTUxD7ErV22eNtxgjA0bDRq63dnqNBtOsOir dSkuXJ2JPeAzsANHqxHA+mlotO9e1nDoJHEx7O7rJh6Gp0TBSL7YcFSHjbzu7XHQGWCbtFciPh cDpjCERoGjXj9NkHTYn+OE1IwunjOLDAprTkQtNB8DDRGk/virNcoAbVKW+69HwX/DR76uzIRk linxKMGa83WL99AZvtmsent2YUYJbTUQ7yzuQW71uuKkwsWnoQvMVODB1Uy2BlbbJCf93wwnhu Znw= X-IronPort-AV: E=Sophos;i="5.79,394,1602572400"; d="scan'208";a="105091237" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Feb 2021 04:38:16 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Tue, 2 Feb 2021 04:38:16 -0700 Received: from kar-sv-agl01.mchp-main.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Tue, 2 Feb 2021 04:38:15 -0700 From: Christian Gromm To: Subject: [PATCH 1/2] staging: most: sound: add sanity check for function argument Date: Tue, 2 Feb 2021 12:38:09 +0100 Message-ID: <1612265890-18246-2-git-send-email-christian.gromm@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1612265890-18246-1-git-send-email-christian.gromm@microchip.com> References: <1612265890-18246-1-git-send-email-christian.gromm@microchip.com> MIME-Version: 1.0 X-BeenThere: driverdev-devel@linuxdriverproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Driver Project Developer List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Gromm , driverdev-devel@linuxdriverproject.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: driverdev-devel-bounces@linuxdriverproject.org Sender: "devel" This patch zero checks the function parameter 'bytes' before doing the subtraction to prevent memory corruption. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter --- drivers/staging/most/sound/sound.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c index 3a1a590..953a4fe 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -86,6 +86,8 @@ static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes) { unsigned int i = 0; + if (!bytes) + return; while (i < bytes - 2) { dest[i] = source[i + 2]; dest[i + 1] = source[i + 1]; -- 2.7.4 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel