Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp785201pxb; Wed, 24 Feb 2021 15:16:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVMRIKf7aWr3a5W8UagGNUBZaKEr+RVuBX3MGPtiRTMRWHGTf6kJ4QbVISt0ALPKE/fX/f X-Received: by 2002:a17:906:3510:: with SMTP id r16mr12560eja.186.1614208575696; Wed, 24 Feb 2021 15:16:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614208575; cv=none; d=google.com; s=arc-20160816; b=XiVTX05ljcQakpMdW73XjTsDBqEZKxRSxM99pWuJrDmAqREfCy/MqdWzqhon+tg35j X4DegmkLpe0FCpTLeEcJuMQSZrFr26XEro04eC3IDRxVz514zamNE3rQK8hJ8no7t8J4 fuGmGzGtgsNAlwC6u2Nt6w8/MGhllQ3NKmsxXao6WZOYTpJl9cENy1x6koZ5bN3CIMXD 80eKWp44RgtL7cC9e8lFTp59d0ZdvxR0soZ3z72Txp9SN2t/KSTv44ULQv58IJNkcXlo Cb5ikjQUcqTQZmX1nB4XvVG8cvR++DSWNDQ8quqUhmExiZczCNKCB1b3hxwn3WP/ekF8 QvpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z589ghjC3Tu/nxPJ4bkAQgH8rdy2C6Tk0tgoIyEkPtY=; b=dZRDP4bN9zwPrWLP6YFj5pFHMUlwoB1iFOi7CpGayL7ZHapsDmXW4YZTITgpS++8ey iiHoDKfId/8nohkjfpK65DF8V/LS4C6lRl1qPcp9ZLD5DuNJimhSJOKlF/X3uz8mjUvr EACiDYr2tzfZhtS8qP/+6KXDox932MbGANbcUoTSCBy5BC+OrdcjkqiSwfh2E8SFcV6O YeDiHOsK9IR8HdfCY/lBgXbLQs6o408iiISNepRR1h5q4hlsNcblTwHfpleN0rujXCUo /Cddqlh8MEQnxdGGvdNLjLv5ybu7M6PoLsO/eM9J1efp6T4+FM1qcz/XYJcIeuT5Glhn xLAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W5qqzU/h"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id du11si2570951ejc.473.2021.02.24.15.15.52; Wed, 24 Feb 2021 15:16:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="W5qqzU/h"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237702AbhBXNma (ORCPT + 99 others); Wed, 24 Feb 2021 08:42:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:58408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235676AbhBXNEg (ORCPT ); Wed, 24 Feb 2021 08:04:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3796E64F6E; Wed, 24 Feb 2021 12:53:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171234; bh=iFGODoxstryWh9z46Hsroy1kCvg8rG/P4tVB0R/u83A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W5qqzU/hgS26D6KpX8yxXfCRF584gSYfU+5u779/8wS4rmi5x289VmgPqW7m/YcVt 0Sb/tGseSLZN+ogNlHP/izE2Bq3U6yco+b6Til85rGyP2Al2LOxHe34Q/WQUdkGTB7 0/sUspYlB7eoM3zG8oVLRS2t9/3Zaq+rJhWy9kiLCIvoJH+29YocuT/KPyX7O2YHvo N7TJGpVh0CSjKI4riW4ydINyu3q/CvnMKl8atsB+8kzT5JgIYjlhpxfUJbYZLGThgT tOX2zal631DCfFz0a3pF068+5d5PTKCNjZzVq0pXgt0Tyo8GfUKllUrza74bmcvFfM t3UDiBePpaXow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christian Gromm , Dan Carpenter , Greg Kroah-Hartman , Sasha Levin , devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 5.4 10/40] staging: most: sound: add sanity check for function argument Date: Wed, 24 Feb 2021 07:53:10 -0500 Message-Id: <20210224125340.483162-10-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125340.483162-1-sashal@kernel.org> References: <20210224125340.483162-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christian Gromm [ Upstream commit 45b754ae5b82949dca2b6e74fa680313cefdc813 ] This patch checks the function parameter 'bytes' before doing the subtraction to prevent memory corruption. Signed-off-by: Christian Gromm Reported-by: Dan Carpenter Link: https://lore.kernel.org/r/1612282865-21846-1-git-send-email-christian.gromm@microchip.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 79817061fcfa4..4225ee9fcf7bf 100644 --- a/drivers/staging/most/sound/sound.c +++ b/drivers/staging/most/sound/sound.c @@ -98,6 +98,8 @@ static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes) { unsigned int i = 0; + if (bytes < 2) + return; while (i < bytes - 2) { dest[i] = source[i + 2]; dest[i + 1] = source[i + 1]; -- 2.27.0