Skip to content
/ linux Public

Commit c9af181

Browse files
Sakari AilusSasha Levin
authored andcommitted
media: ccs: Avoid possible division by zero
[ Upstream commit 679f0b7 ] 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@kernel.org> Closes: https://lore.kernel.org/all/ahukd6b3wonye3zgtptvwzvrxldcruazs2exfvll6etjhmcxyj@vq3eh6pd375b/ Fixes: ccfc97b ("[media] smiapp: Add driver") Cc: stable@vger.kernel.org # for 5.15 and later Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> # build Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0c074e8 commit c9af181

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/media/i2c/ccs/ccs-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2386,7 +2386,7 @@ static void ccs_set_compose_scaler(struct v4l2_subdev *subdev,
23862386
* CCS_LIM(sensor, SCALER_N_MIN) / sel->r.height;
23872387
max_m = crops[CCS_PAD_SINK]->width
23882388
* CCS_LIM(sensor, SCALER_N_MIN)
2389-
/ CCS_LIM(sensor, MIN_X_OUTPUT_SIZE);
2389+
/ (CCS_LIM(sensor, MIN_X_OUTPUT_SIZE) ?: 1);
23902390

23912391
a = clamp(a, CCS_LIM(sensor, SCALER_M_MIN),
23922392
CCS_LIM(sensor, SCALER_M_MAX));

0 commit comments

Comments
 (0)