[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20251125232438.GA193422@ax162>
Date: Tue, 25 Nov 2025 16:24:38 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Sakari Ailus <sakari.ailus@...ux.intel.com>
Cc: linux-media@...r.kernel.org, Josh Poimboeuf <jpoimboe@...nel.org>,
Ingo Molnar <mingo@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] media: ccs: Avoid possible division by zero
On Tue, Nov 25, 2025 at 01:00:45AM +0200, Sakari Ailus wrote:
> Calculating maximum M for scaler configuration involves dividing by
> MIN_X_OUTPUT_SIZE limit register's value. Albeit the value is presumably
> non-zero, the driver was missing the check it in fact was. Fix this.
>
> Reported-by: Josh Poimboeuf <jpoimboe@...nel.org>
> Closes: https://lore.kernel.org/all/ahukd6b3wonye3zgtptvwzvrxldcruazs2exfvll6etjhmcxyj@vq3eh6pd375b/
> Fixes: ccfc97bdb5ae ("[media] smiapp: Add driver")
> Cc: stable@...r.kernel.org # for 5.15 and later
> Signed-off-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
> ---
This clears up the objtool warning for me.
Reviewed-by: Nathan Chancellor <nathan@...nel.org>
Tested-by: Nathan Chancellor <nathan@...nel.org> # build
> drivers/media/i2c/ccs/ccs-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
> index f8523140784c..dadff8c50679 100644
> --- a/drivers/media/i2c/ccs/ccs-core.c
> +++ b/drivers/media/i2c/ccs/ccs-core.c
> @@ -2346,7 +2346,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev,
> * CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height;
> max_m = crops[CCS_PAD_SINK]->width
> * CCS_LIM(sensor, SCALER_N_MIN)
> - / CCS_LIM(sensor, MIN_X_OUTPUT_SIZE);
> + / (CCS_LIM(sensor, MIN_X_OUTPUT_SIZE) ?: 1);
>
> a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN),
> CCS_LIM(sensor, SCALER_M_MAX));
> --
> 2.47.3
>
Powered by blists - more mailing lists