net/mlx4: Use array_size() helper in copy_to_user()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 28 Sep 2021 20:17:33 +0000 (15:17 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 29 Sep 2021 10:32:14 +0000 (11:32 +0100)
Use array_size() helper instead of the open-coded version in
copy_to_user(). These sorts of multiplication factors need
to be wrapped in array_size().

Link: https://github.com/KSPP/linux/issues/160
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/cq.c

index f7053a7..4d4f9cf 100644 (file)
@@ -314,7 +314,8 @@ static int mlx4_init_user_cqes(void *buf, int entries, int cqe_size)
                        buf += PAGE_SIZE;
                }
        } else {
-               err = copy_to_user((void __user *)buf, init_ents, entries * cqe_size) ?
+               err = copy_to_user((void __user *)buf, init_ents,
+                                  array_size(entries, cqe_size)) ?
                        -EFAULT : 0;
        }