Skip to content

Commit 92fbb6d

Browse files
harperchenwsakernel
authored andcommitted
i2c: xgene-slimpro: Fix out-of-bounds bug in xgene_slimpro_i2c_xfer()
The data->block[0] variable comes from user and is a number between 0-255. Without proper check, the variable may be very large to cause an out-of-bounds when performing memcpy in slimpro_i2c_blkwr. Fix this bug by checking the value of writelen. Fixes: f6505fb ("i2c: add SLIMpro I2C device driver on APM X-Gene platform") Signed-off-by: Wei Chen <[email protected]> Cc: [email protected] Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent d982635 commit 92fbb6d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/i2c/busses/i2c-xgene-slimpro.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ static int slimpro_i2c_blkwr(struct slimpro_i2c_dev *ctx, u32 chip,
308308
u32 msg[3];
309309
int rc;
310310

311+
if (writelen > I2C_SMBUS_BLOCK_MAX)
312+
return -EINVAL;
313+
311314
memcpy(ctx->dma_buffer, data, writelen);
312315
paddr = dma_map_single(ctx->dev, ctx->dma_buffer, writelen,
313316
DMA_TO_DEVICE);

0 commit comments

Comments
 (0)