From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAD51350D7B; Tue, 26 Aug 2025 14:26:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756218360; cv=none; b=Rqthgv9v1Fx9A3wxZap91qCQP/fK/Hf+wYkU4vENPsBV7oQZjw79nIelc+G0autwv92mSqEPqxehIqBmohCXfmTXg4XSPn3S8l+WE6dIRcEw/W+w7TzrbeieIiVKtKr4nHbtr/80a7XaTJmkEfxdWzZuThD8qF5oArD/SGKsX5E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756218360; c=relaxed/simple; bh=h1zn6Pkz7HGr2U6EKWtzzXwjWV35L8VCHy4o64ohdBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AuGvL7VPx8Nn/g9j8SeAtgNfAjlzfirVebAQvvQhp/1F5DqHOXwjDL1XeXBCUAlO68tOCBWs2ySwvw0nNOLAsju/n8YfyS7Jr4h1C96Dqxy45jvPxJgagGLAB0PPMA5XXYy+JwGUDM1BW8C697DhK+9tA6kdL/3M1137LRLGxYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0o42/Ftw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0o42/Ftw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAF5EC4CEF1; Tue, 26 Aug 2025 14:25:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756218360; bh=h1zn6Pkz7HGr2U6EKWtzzXwjWV35L8VCHy4o64ohdBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0o42/Ftw/P1wzVFT8va3LocNklYVuzCnIapSml2ENZ/mFYx+fu5LXxA8hJczfWQCz k1u4AS5xGrTV7d2Aob9He4bZKh2hntYXn0zWqQ1pXd65fKvwLhInBeimSSh8c3CG2c IBI34t5mM8dHqDUhFZ7FfUqdWoNDP4NS3/HTNLLA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hans Verkuil , Bryan ODonoghue , Ricardo Ribalda , Bryan ODonoghue , Sasha Levin Subject: [PATCH 5.10 492/523] media: venus: vdec: Clamp param smaller than 1fps and bigger than 240. Date: Tue, 26 Aug 2025 13:11:42 +0200 Message-ID: <20250826110936.581119772@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110924.562212281@linuxfoundation.org> References: <20250826110924.562212281@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ricardo Ribalda [ Upstream commit 377dc500d253f0b26732b2cb062e89668aef890a ] The driver uses "whole" fps in all its calculations (e.g. in load_per_instance()). Those calculation expect an fps bigger than 1, and not big enough to overflow. Clamp the value if the user provides a param that will result in an invalid fps. Reported-by: Hans Verkuil Closes: https://lore.kernel.org/linux-media/f11653a7-bc49-48cd-9cdb-1659147453e4@xs4all.nl/T/#m91cd962ac942834654f94c92206e2f85ff7d97f0 Fixes: 7472c1c69138 ("[media] media: venus: vdec: add video decoder files") Cc: stable@vger.kernel.org Tested-by: Bryan O'Donoghue # qrb5615-rb5 Reviewed-by: Bryan O'Donoghue Signed-off-by: Ricardo Ribalda [bod: Change "parm" to "param"] Signed-off-by: Bryan O'Donoghue Signed-off-by: Hans Verkuil Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/qcom/venus/core.h | 2 ++ drivers/media/platform/qcom/venus/vdec.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) --- a/drivers/media/platform/qcom/venus/core.h +++ b/drivers/media/platform/qcom/venus/core.h @@ -25,6 +25,8 @@ #define VIDC_VCODEC_CLKS_NUM_MAX 2 #define VIDC_PMDOMAINS_NUM_MAX 3 +#define VENUS_MAX_FPS 240 + extern int venus_fw_debug; struct freq_tbl { --- a/drivers/media/platform/qcom/venus/vdec.c +++ b/drivers/media/platform/qcom/venus/vdec.c @@ -427,11 +427,10 @@ static int vdec_s_parm(struct file *file us_per_frame = timeperframe->numerator * (u64)USEC_PER_SEC; do_div(us_per_frame, timeperframe->denominator); - if (!us_per_frame) - return -EINVAL; - + us_per_frame = clamp(us_per_frame, 1, USEC_PER_SEC); fps = (u64)USEC_PER_SEC; do_div(fps, us_per_frame); + fps = min(VENUS_MAX_FPS, fps); inst->fps = fps; inst->timeperframe = *timeperframe;