Commit 6123f1fe authored by Dan Carpenter's avatar Dan Carpenter Committed by Greg Kroah-Hartman

misc: xilinx_sdfec: Prevent integer overflow in xsdfec_table_write()

The checking here needs to handle integer overflows because "offset" and
"len" come from the user.

Fixes: 20ec628e ("misc: xilinx_sdfec: Add ability to configure LDPC")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarMichal Simek <michal.simek@xilinx.com>
Reviewed-by: default avatarDragan Cvetic <dragan.cvetic@xilinx.com>
Link: https://lore.kernel.org/r/20190821071122.GD26957@mwandaSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 56a635c0
...@@ -611,7 +611,9 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset, ...@@ -611,7 +611,9 @@ static int xsdfec_table_write(struct xsdfec_dev *xsdfec, u32 offset,
* Writes that go beyond the length of * Writes that go beyond the length of
* Shared Scale(SC) table should fail * Shared Scale(SC) table should fail
*/ */
if ((XSDFEC_REG_WIDTH_JUMP * (offset + len)) > depth) { if (offset > depth / XSDFEC_REG_WIDTH_JUMP ||
len > depth / XSDFEC_REG_WIDTH_JUMP ||
offset + len > depth / XSDFEC_REG_WIDTH_JUMP) {
dev_dbg(xsdfec->dev, "Write exceeds SC table length"); dev_dbg(xsdfec->dev, "Write exceeds SC table length");
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment