linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Christian Gromm <christian.gromm@microchip.com>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Sasha Levin <sashal@kernel.org>,
	devel@driverdev.osuosl.org
Subject: [PATCH AUTOSEL 4.9 09/12] staging: most: sound: add sanity check for function argument
Date: Wed, 24 Feb 2021 07:55:37 -0500	[thread overview]
Message-ID: <20210224125540.484221-9-sashal@kernel.org> (raw)
In-Reply-To: <20210224125540.484221-1-sashal@kernel.org>

From: Christian Gromm <christian.gromm@microchip.com>

[ Upstream commit 45b754ae5b82949dca2b6e74fa680313cefdc813 ]

This patch checks the function parameter 'bytes' before doing the
subtraction to prevent memory corruption.

Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/1612282865-21846-1-git-send-email-christian.gromm@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 e4198e5e064b5..288c7bf129457 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


  parent reply	other threads:[~2021-02-24 14:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24 12:55 [PATCH AUTOSEL 4.9 01/12] staging: fwserial: Fix error handling in fwserial_create Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 02/12] x86/reboot: Add Zotac ZBOX CI327 nano PCI reboot quirk Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 03/12] vt/consolemap: do font sum unsigned Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 04/12] wlcore: Fix command execute failure 19 for wl12xx Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 05/12] pktgen: fix misuse of BUG_ON() in pktgen_thread_worker() Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 06/12] ath10k: fix wmi mgmt tx queue full due to race condition Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 07/12] x86/build: Treat R_386_PLT32 relocation as R_386_PC32 Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 08/12] Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data Sasha Levin
2021-02-24 12:55 ` Sasha Levin [this message]
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 10/12] media: uvcvideo: Allow entities with no pads Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 11/12] tomoyo: ignore data race while checking quota Sasha Levin
2021-02-24 12:55 ` [PATCH AUTOSEL 4.9 12/12] smackfs: restrict bytes count in smackfs write functions Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210224125540.484221-9-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=christian.gromm@microchip.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).