diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-08-21 09:09:53 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-08-22 23:28:10 +0200 |
commit | 56a635c0ec14950bd6a5bfb4d9d497897f64179f (patch) | |
tree | 0e962948a9fa8fe4a58057d6b40a877dbd7c3f50 /drivers/misc/xilinx_sdfec.c | |
parent | misc: xilinx_sdfec: Return -EFAULT if copy_from_user() fails (diff) | |
download | linux-56a635c0ec14950bd6a5bfb4d9d497897f64179f.tar.xz linux-56a635c0ec14950bd6a5bfb4d9d497897f64179f.zip |
misc: xilinx_sdfec: Prevent a divide by zero in xsdfec_reg0_write()
The "psize" value comes from the user so we need to verify that it's
non-zero before we check if "n % psize" or it will crash.
Fixes: 20ec628e8007 ("misc: xilinx_sdfec: Add ability to configure LDPC")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michal Simek <michal.simek@xilinx.com>
Link: https://lore.kernel.org/r/20190821070953.GC26957@mwanda
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc/xilinx_sdfec.c')
-rw-r--r-- | drivers/misc/xilinx_sdfec.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/misc/xilinx_sdfec.c b/drivers/misc/xilinx_sdfec.c index 813b82c59360..3fc53d20abf3 100644 --- a/drivers/misc/xilinx_sdfec.c +++ b/drivers/misc/xilinx_sdfec.c @@ -460,7 +460,7 @@ static int xsdfec_reg0_write(struct xsdfec_dev *xsdfec, u32 n, u32 k, u32 psize, { u32 wdata; - if (n < XSDFEC_REG0_N_MIN || n > XSDFEC_REG0_N_MAX || + if (n < XSDFEC_REG0_N_MIN || n > XSDFEC_REG0_N_MAX || psize == 0 || (n > XSDFEC_REG0_N_MUL_P * psize) || n <= k || ((n % psize) != 0)) { dev_dbg(xsdfec->dev, "N value is not in range"); return -EINVAL; |