Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1979819pxb; Fri, 5 Mar 2021 04:40:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwdNAIDPc96R2ATknCMF1eak5CJaax7TKmMXsBLEnmm5gpqhRIHcCYNbw9PAzmUAp0JdKD3 X-Received: by 2002:a17:906:719b:: with SMTP id h27mr2008696ejk.123.1614948027956; Fri, 05 Mar 2021 04:40:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614948027; cv=none; d=google.com; s=arc-20160816; b=MPipDHEtkdWKiC0pTDcPHjfu2IOIGY9Sa7S0Eq6WJT6RSLywZ+7u0qttvmjiB+f8Pn jjaNya7xUpT6uotCwRSyyKoqg5UlaCfIF6b28Z+A42pmV05M8T5N39iVrcT5OgtUuWw2 C/jpaSieo2kxTv4SIoZlGfwdJ1xcGwqsR1MwYYgnhvGn+gTukZKhrJ6RjUkc8jthT/Mp Cuwb1KumpnmkHFppob86vNYoGt/M+KFw8cMNrooRK+SF8h3BNOHu0DyP1cyFN7aF5H9e XGXg0vVrg8FdBDpKYz9/1iKr0H70NXqLzrSLxPRo0usfJi6kx93BDdEPl9UoMVwJiQ9u FY3Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R6FTq9C5hyWpMZsiK85q0vTLjkIKU6U3+mEUZ5JpMzE=; b=Jcz/IEttf4Z25U2wIzTxNL9a57rnjKzBycBfD58NAJTeVZD56kcXz5YyaPc7Un2b3m GTCeTpGLDLFkoVD4MMpxlACuB6yeVRJ3RloNXMaIgQZsbmodPeMBWk14d0RLGdZ41w4+ si0K5Oy38hXPQV6yfjTn1WlYWQyF8CIAQ5MEGW1uKCSoLYXVPvH892CfN5jHlIVT859B 51J1HbWPM4Ywv6wx17XBzVeGF2AwbQCzCOb0sNdAcirTupUqfdxItAwfHT//TSlUZsFC LD1KeWs628UGGqs5BGvPEILiYTX59s1zwynd6HYIkiVj197Xflg7U6s0BYF3/Mmf56oT AFBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cvOzxHzF; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e22si1522951edu.9.2021.03.05.04.40.04; Fri, 05 Mar 2021 04:40:27 -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=@linuxfoundation.org header.s=korg header.b=cvOzxHzF; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233163AbhCEMjI (ORCPT + 99 others); Fri, 5 Mar 2021 07:39:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:52076 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232830AbhCEMi1 (ORCPT ); Fri, 5 Mar 2021 07:38:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0BFB46501D; Fri, 5 Mar 2021 12:38:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947904; bh=QKlhfge7VBouI/yVxkROOjTtlX5LpXm6OJM/jBXLAA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvOzxHzFRU8ZDK175lxuZ4Pit+61q9yrmG4/TU94huARtOtmt+WzABRk1KUmDeyFD RXQLyQu8AwjII5gSzszUCYfLceqN4feZZk/LixK921eWqFcgQMH8a2ucdeBkm052L0 LCu7KEzaDJhRqLC/4zzkgJnEH2cPtwEkr0sxSCJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christian Gromm , Dan Carpenter , Sasha Levin Subject: [PATCH 4.19 30/52] staging: most: sound: add sanity check for function argument Date: Fri, 5 Mar 2021 13:22:01 +0100 Message-Id: <20210305120855.157148641@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120853.659441428@linuxfoundation.org> References: <20210305120853.659441428@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 89b02fc305b8..fd9245d7eeb9 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.30.1