From nobody Mon Feb 9 01:32:21 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 256B619995E for ; Wed, 8 Jan 2025 09:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736328532; cv=none; b=ljqRwtPLfeP05cYfw73gDTHfVVfcSXMD1KWdGrFHUvU1gnrDBcEso8sXpNyk/ePNRl9WUO8a0fntrD+w5wzLx5DgJckogU4179ZLSTJKmMInVu4MfuuTyC3GDgkBXK5ALE0icvITEjFjB8TfGbn9ssalFG9js7M2y0V1tOrn8ys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736328532; c=relaxed/simple; bh=yA7y97nb85po90Zmk69+gL//XzthbasJe+UKvQBCBIQ=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=AOQJVu2BtwuCd5Bh8FR/pHcGWfPyJeBlzh/AO+t8IvDJJkV161H78QZHj6i8u7dkkDmDt9dp42SFufm7nfdz91wDnc++kdKvfsFdQl77R06W+IdIlfbxQxXVnCmWihOQFuZwdwt2oJQ4261MUIytgZ+An6znNSBXEIWwJRSSBhI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Vrv62d0K; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Vrv62d0K" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-43623f0c574so113551855e9.2 for ; Wed, 08 Jan 2025 01:28:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736328529; x=1736933329; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=ksX/kLob51zQcWxh1cMQc5uB7HVLI56lSlw1NK1rQYU=; b=Vrv62d0KBPN9aT7G2fo5sRAsLw8PLpQzbuSWTiOTOcNzO14J8fnCloQgcZWp+vQQ6Z ioGAewjcotWKLQjXrH3+PZO/W5zPNyN04BTvD3Gw7P9U4B30GOLOKiUqo+soA7GkXfk+ 7ShBx+KLuCUyIH02GGBh2aJOHp2s++6fprb7RquxyktEpPwf53Oq6siW1Lo4vaZFpn+U jpgq0zTz9aI3uiJS1rltkK/WTWIEcYqQh2BYHmts8eQ7KwbTZY01uPXhGhw6Mrk3LYZT Jgi+gjpL9DlSfXjsltToLgTa7XrGPaDz7B+v4pB+vnOikr+RRoQAYx1pYt47kwnu8umD k7jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736328529; x=1736933329; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ksX/kLob51zQcWxh1cMQc5uB7HVLI56lSlw1NK1rQYU=; b=lg4+zGRAPVkowi5zasBGQCDQ+w0wW2SdsTbJyJ9g+gn4u+62tCFmN4Qy+dYTN8C0nn YMAXH4s3Eg4RIkrmr56ZC9j306BnqqWXAXSb/jSpR2SIGd8h3KQJ7L4vF+I0yndO2cAU oGL86kEkGJuHfGNt47tmHLvbIOJLFen0R10pNzrvLx/iCuX6osBoseGad7vP9hkOAwTd 8j7bWzx2iGH+AMzxlDj3mrBSIxHz0l6MNyPIBY0wE7uW6zmMCYc9dnJHl+p+2SGsMar5 DWOqS8MDnVXBOm3Cu7LWj8rvze2wPOL4T/3djaU3rA8GlvwGucA3SqLf0XmVSpJ1ss9w 6T7g== X-Forwarded-Encrypted: i=1; AJvYcCW30NFly6cSMuHazciKOjHbWB6plm5/uPHqStCumRdzNeGGa+gyTBQPD80NtHYxzrPbo7UmCfdE81gBceA=@vger.kernel.org X-Gm-Message-State: AOJu0YzyXMosy5Xrznlz6c4JfwarLAaEN68havJgVnmBVGVAHMRJKrYA AgJ3+QO81OwpEQlIIpAp/iV8iZRpkeYNu1R19ryTbnVuo86H/KSvGorx8KHofcKc5z9W7afLl6A R X-Gm-Gg: ASbGncvp8R1+Ormof2eJ/ZOJvM+J4iJ2/Y38Wo8rVfBSKCGlaGfhnZgGvzJZpXKqz0G qXela+Q5HEZMJmX/MlMsK/D6J4W2AVRJewFKStSfcugaF8nbQj3PdpFf57P36syCz4sKK5453kH lc9qqrMZ6qOgk7MjMlcYVwIdAyK891rhlmYLluSAN6EvOLcSADGb5xmQoz4R73fPZUHphfrSUhL OEFA2oaVuIgOlKHRQq1crx826nPYjuuVZPigdxUHmYINkYPIMdO2D0tQK4mSA== X-Google-Smtp-Source: AGHT+IEbOKQpbXnV0Vk4QEqZakle2mY4HuBVWDf4SPOXo+NOnQPd/LEFfiqdZj1V2NZzu8Gu4CgtXQ== X-Received: by 2002:a05:600c:1d82:b0:434:f953:efb with SMTP id 5b1f17b1804b1-436e26f984amr12953225e9.32.1736328529560; Wed, 08 Jan 2025 01:28:49 -0800 (PST) Received: from localhost ([196.207.164.177]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-436e2e92f60sm13995695e9.40.2025.01.08.01.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jan 2025 01:28:49 -0800 (PST) Date: Wed, 8 Jan 2025 12:28:46 +0300 From: Dan Carpenter To: Biju Das Cc: Lad Prabhakar , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-sound@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ASoC: renesas: rz-ssi: Add a check for negative sample_space Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" My static checker rule complains about this code. The concern is that if "sample_space" is negative then the "sample_space >=3D runtime->channels" condition will not work as intended because it will be type promoted to a high unsigned int value. strm->fifo_sample_size is SSI_FIFO_DEPTH (32). The SSIFSR_TDC_MASK is 0x3f. Without any further context it does seem like a reasonable warning and it can't hurt to add a check for negatives. Cc: stable@vger.kernel.org Fixes: 03e786bd4341 ("ASoC: sh: Add RZ/G2L SSIF-2 driver") Signed-off-by: Dan Carpenter Reviewed-by: Geert Uytterhoeven --- sound/soc/renesas/rz-ssi.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/renesas/rz-ssi.c b/sound/soc/renesas/rz-ssi.c index d48e2e7356b6..3a0af4ca7ab6 100644 --- a/sound/soc/renesas/rz-ssi.c +++ b/sound/soc/renesas/rz-ssi.c @@ -521,6 +521,8 @@ static int rz_ssi_pio_send(struct rz_ssi_priv *ssi, str= uct rz_ssi_stream *strm) sample_space =3D strm->fifo_sample_size; ssifsr =3D rz_ssi_reg_readl(ssi, SSIFSR); sample_space -=3D (ssifsr >> SSIFSR_TDC_SHIFT) & SSIFSR_TDC_MASK; + if (sample_space < 0) + return -EINVAL; =20 /* Only add full frames at a time */ while (frames_left && (sample_space >=3D runtime->channels)) { --=20 2.45.2