Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp443502pxb; Wed, 24 Feb 2021 06:25:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJy8etfzh0O9DWdN9TzydnfTRNBTqWjLpEUwlM5Z1+oontStADAivjvxAoSVdMvz4MVx8nY3 X-Received: by 2002:a17:906:3409:: with SMTP id c9mr1872604ejb.314.1614176750150; Wed, 24 Feb 2021 06:25:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614176750; cv=none; d=google.com; s=arc-20160816; b=HOJGTSltemdfQ08QHM2RD69lGNa152wXgc4/0WGTwj625e9StdXZHE4AJenODuyjKk cY+ODupraJO/eTvwq+jB9OZ2QKox+Ashxd0p78jMpbLuXV1Hx2FGfrivSzJmLyX3sM+w gDHz/3DyTjnOlvHZ5m/0bIqZ45iyFlUrcT58lYjGnzWfGteCBbTfR66LwEenXlbiP0uc g7OxCDA/aPCs1z9mxM9T/4RBJf1TYYO6y2PEUth3jtYxbE5Due2EmxUPuxLwKafafIWD bLxUY2DMFq2YAdIfDQmCNzIDmDJY7ocpvkx/EXA+o+QnaYmT5m0vNen4uTlxk4WS+RlB TBrQ== 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=/5SGKzXrMg+Di+f4B6Gf46DI3h8rjH6ne0CArivCKHM=; b=pW4/vR2MuLpl0/oaVenLq9jhuHO+XNjr8pRt9iGx7PEzT1ESsvcLWo5o22V9sDEK9a +MLzBv7hUyu7eAdhTI1Dax92KnBAoVZ86JX3RYaDj6wBrxtn7xQVlx25n03qKdB2JJ95 LfAsh5fr64MFYDZHMZczS5G0MxTnDY+HjDClDn/+W6pLT0wthoaCXobGFZ30z6VGuEXA Ywndw4O+adgAIfYKXIFmyw5BskwRutQ8w+S1Agaqs44fTW0dqIHPTvVqoAZH9bk8US92 F61fBsHFpq9sflUVcsS+UgSsQzBhgGUqn27udiYhNTbP6EJ0Ca/N5oWLmez4vnRrzaOt KBzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Kou9wJry; 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 t12si1288235edc.228.2021.02.24.06.25.14; Wed, 24 Feb 2021 06:25:50 -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=Kou9wJry; 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 S236289AbhBXOSt (ORCPT + 99 others); Wed, 24 Feb 2021 09:18:49 -0500 Received: from mail.kernel.org ([198.145.29.99]:58410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236023AbhBXNI1 (ORCPT ); Wed, 24 Feb 2021 08:08:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B042564F95; Wed, 24 Feb 2021 12:54:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171288; bh=lUJimLn+T5S/ny3LbdJ97oMNo6gihYSp2aP0IgO8R/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Kou9wJry9tQok+zfnxgP0QrLh05fuPVrTF5uTbw01pQNqNKyDaqpEsUgAH+9PJslg wHEJiCqbjmXmCL9aldSJvkFNvZMPnin7n2ZznkxLBxYiDjbcvUB3Ctz4K4wKaaNLnX 70/bJQWoX3et1kzwmhKYu5OR1faeNGwSCIQ0kZscnvb8KA3quXEEhRCLF3aj4o4Do3 ShNHdx8X8/6eJ91ayStZtGKwc/js/co2nwk42I9WK+hyR4c2/SeRSj1j1nHlQHgm4e 210dsDEqQJBigV0ObQTz76k5uqt9KhHW0mlXWPpoeEIKBhcQQhyH13L7SpesRjK8wn kn2qNdgdK6cgA== 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 4.19 10/26] staging: most: sound: add sanity check for function argument Date: Wed, 24 Feb 2021 07:54:18 -0500 Message-Id: <20210224125435.483539-10-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125435.483539-1-sashal@kernel.org> References: <20210224125435.483539-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 89b02fc305b8b..fd9245d7eeb9a 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 < 2) + return; while (i < bytes - 2) { dest[i] = source[i + 2]; dest[i + 1] = source[i + 1]; -- 2.27.0