Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1978355pxb; Fri, 5 Mar 2021 04:38:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWPoY+hEioKqc713/dRjIbL1P+FwVCD/q1u8PKR/mu9aqLh4/0LUInNB2ZDRrnLZCNy71P X-Received: by 2002:a05:6402:2215:: with SMTP id cq21mr9080929edb.281.1614947885627; Fri, 05 Mar 2021 04:38:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947885; cv=none; d=google.com; s=arc-20160816; b=T/zLljQAbol/7u7R1lzMQoEoEgU9mHhkLWZcFMJKGVl/Kc2EWiE6/NivDBQs/xstK5 m687mWrR//hOOAjmlECZUjBXQT0McTa/WVxbRglaJf4GA/h62IHr3MFbJegytjg1dkgr wqMnyIKu6WqNBoDOTSkt5FaTCKZB2G5U5yqPkKkn6uVtGW9YxbsOYOKVZ0UGV4eCvbuT cL5RALKW8nERRkUPS9vj4YdJllxpa116eT9ycjmkzGT4mQK+qfiLs8fmNF2UaXLO5FTq +To5UHElH553OXEmCsFgMqUXLLr/zYkRCmEGkGCVDWdDhH5S26rOXyLiN1emY/PI7YKS oV5Q== 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=J2/NiPqeXgm+Br2J0PTXKOIOApDv2H0I8mjSKC61fF4=; b=wtOqZTiYSlCOgSrsSrPQAU59qbgjvfyVbkfpXwmXCkVLeFiOKOKGnyKADrPdbeKOar sHXb70VLSe7r4jFFXiVoAAfWvzJMHKR4S+eqtLymOIRuqvD2bNCp4KtEjENyJb7mmc9/ vY3jPw1Z+SX5JFbm0a1fV3sIKDYEb+OPN8J/l4dteG5D3rux1m9KNFuOX4OtMYWtR+mR RSp4P2beoQC33FKsF/Va91hy1ielMQxp0NGa7uzXuVdp/CLHK5cwRDC7qMxkrHFFmzuH iB7k6sRb+Tg8hn8PfXxCeVecvfxGLC9jRf6wFgXa9py0OnV96PRpbbSM/UfXyM6Sn28l Yv8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dDGxPy7i; 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 y18si1413145edr.411.2021.03.05.04.37.40; Fri, 05 Mar 2021 04:38:05 -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=dDGxPy7i; 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 S232587AbhCEMey (ORCPT + 99 others); Fri, 5 Mar 2021 07:34:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:45694 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231913AbhCEMeQ (ORCPT ); Fri, 5 Mar 2021 07:34:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 71F6E6501E; Fri, 5 Mar 2021 12:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947656; bh=XJtq7N0OduMxiab5Xx1dDMG2uZSsM65YMf+EmV2SkYk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dDGxPy7idoDahOPd498L2a6fkFRkfe1ATIqIfPncHUzisoBJEmcdORcj6nPS5Boy7 nFOORLNgIfqMdIQ77d6Pg22k86TGD5p1BanbFsqzNyBzTd94/tRRSETrgJ7vbhDnWh W9OeOE7G/kW4ZM1rLxbe+Q7dz/522dyK27a3djm8= 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 5.4 37/72] staging: most: sound: add sanity check for function argument Date: Fri, 5 Mar 2021 13:21:39 +0100 Message-Id: <20210305120859.157578757@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120857.341630346@linuxfoundation.org> References: <20210305120857.341630346@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 79817061fcfa..4225ee9fcf7b 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.30.1