Skip to content

Commit 5ad2e46

Browse files
Marco Felschmchehab
authored andcommitted
media: i2c: tc358746: fix possible endianness issue
Using the u64 v4l2_dbg_register.val directly can lead to unexpected results depending on machine endianness. Fix this by using a local variable which is assigned afterwards. Since tc358746_read() will init the val variable to 0 we can assing it without checking the return value first. Addresses-Coverity-ID: 1527256 ("Integer handling issues") Reported-by: coverity-bot <keescook+coverity-bot@chromium.org> Fixes: 80a21da ("media: tc358746: add Toshiba TC358746 Parallel to CSI-2 bridge driver") Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 9d33802 commit 5ad2e46

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/media/i2c/tc358746.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,7 @@ static int __maybe_unused
988988
tc358746_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
989989
{
990990
struct tc358746 *tc358746 = to_tc358746(sd);
991+
u32 val;
991992
int err;
992993

993994
/* 32-bit registers starting from CLW_DPHYCONTTX */
@@ -996,7 +997,8 @@ tc358746_g_register(struct v4l2_subdev *sd, struct v4l2_dbg_register *reg)
996997
if (!pm_runtime_get_if_in_use(sd->dev))
997998
return 0;
998999

999-
err = tc358746_read(tc358746, reg->reg, (u32 *)&reg->val);
1000+
err = tc358746_read(tc358746, reg->reg, &val);
1001+
reg->val = val;
10001002

10011003
pm_runtime_mark_last_busy(sd->dev);
10021004
pm_runtime_put_sync_autosuspend(sd->dev);

0 commit comments

Comments
 (0)