Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp440828pxb; Wed, 24 Feb 2021 06:21:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVcz66tZqRMmYnh3ZPAHCz7JrLXXzrHvq/WZzv7ywFQPYSBMjs+dlyMX8PH3PHj6FDsy6Q X-Received: by 2002:a17:906:27cc:: with SMTP id k12mr31832129ejc.8.1614176514725; Wed, 24 Feb 2021 06:21:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614176514; cv=none; d=google.com; s=arc-20160816; b=yLBDq+V96B1jf2pO3zmumtBdWUpoqxVQ1MNlo8odJu4xoDHkUEkfrldmFpLL3+h0GD ChMMtK2bPT27olKLg0lhdtbfFqIyWCc6mBAUevEcW4H57eCDaYfyHvnFWvYCrWkWKr7F 3SI5P0pJBenV2ojOWpc5+xuYjosrnhFJqkTq4WZFkHPwd9QwalUi4zn42/t9aQlxM1He cob4UTmHbjun35AC3JyneNrZ+SE57TSbl2cN1dGxulhweTre9FMIKqjyZAmbOzAZu6oi abMUMm8KDoD0+3lATGTqvg/0+rS+6mxV54DQiemEsj/TrQjQIUkgElYZmJTSHO4HmV3E vdug== 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=lXawfMWLAMv5HSAwO6oq8VUzTWYNCQ/YOYDuCSp3Jqo=; b=yGdVtu9Y8v52Y1DGxuRNVUQlm4N/PoMKx3A6xf57xISRKrxhYPXbaBuGeKjbcxQnbs Fim9iC8FKIWMHO+ev9IBhKpN2J37a/fNFzAXqKHcPaSEqIPs455stwUFuk2fDR77MvTh FGwFW/KeMZc4hUPWwSDd18xoU6jKmzSAHtJPCwMZ8WIv4et5Bz+8GrpnLgvF47ywEqbw tdG7VHcOOdQfXaVmi6PMXyLPCFF9dfkxoKHYbhW5UqtvRMX4MAXbRs7rRbD1RfeM/ISj 2gkDDQHWtwM01AOIGkSPzS4aJjLMgaZgHWU03uTeg5x0NP+Z0q100td3XMa3fv2RMNxl 0log== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jORAUISR; 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 dk24si1248142edb.238.2021.02.24.06.21.03; Wed, 24 Feb 2021 06:21:54 -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=jORAUISR; 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 S236060AbhBXOPb (ORCPT + 99 others); Wed, 24 Feb 2021 09:15:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:59878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234796AbhBXNLL (ORCPT ); Wed, 24 Feb 2021 08:11:11 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D66D664F9C; Wed, 24 Feb 2021 12:55:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171326; bh=3bDrxiJIxCJ6ws1uYlYE4vk36EcokGT9rHS0DnfDQ08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jORAUISRZTsLf6X8907z3S2NmrkkRod6hsePmMZuYdn1/g+nze/7B7y/aReOxs+kd TBqZDoB5eI40H+DtajcesbVlX07aN1AURIitpsCMNssbY+eAqZ1VMdt1+MhCKqugw+ YYz7AIHPy44aSOu2p7a8TETa9RvZoTZWf8v5UI2JLZtNtfMPRxsVx0rNrrAV6qa1/z IxQIXrwy1EqKbJ1y/bLM0H71k4sUlMRAtk+tGcyjWv8HoNIiSGdJgDPp9/yO8ir3IP DFbmHc2evHkY7M6QBm3B4tthEpaNY43p/8qorka0nGyjOn9/LyiB9dIAjdv8nMvhhA fOR/a4nR+Gb5g== 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.14 09/16] staging: most: sound: add sanity check for function argument Date: Wed, 24 Feb 2021 07:55:06 -0500 Message-Id: <20210224125514.483935-9-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125514.483935-1-sashal@kernel.org> References: <20210224125514.483935-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/aim-sound/sound.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/most/aim-sound/sound.c b/drivers/staging/most/aim-sound/sound.c index ea1366a440083..e259bf4956ab6 100644 --- a/drivers/staging/most/aim-sound/sound.c +++ b/drivers/staging/most/aim-sound/sound.c @@ -92,6 +92,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