[next] bcachefs: Use array_size() in call to copy_from_user()

Message ID ZYDjMgyrFYhOsazc@work
State New
Headers
Series [next] bcachefs: Use array_size() in call to copy_from_user() |

Commit Message

Gustavo A. R. Silva Dec. 19, 2023, 12:26 a.m. UTC
  Use array_size() helper, instead of the open-coded version in
call to copy_from_user().

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 fs/bcachefs/chardev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Kent Overstreet Dec. 19, 2023, 1:29 a.m. UTC | #1
On Mon, Dec 18, 2023 at 06:26:26PM -0600, Gustavo A. R. Silva wrote:
> Use array_size() helper, instead of the open-coded version in
> call to copy_from_user().
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Applied
  

Patch

diff --git a/fs/bcachefs/chardev.c b/fs/bcachefs/chardev.c
index 304ea619a888..22a52bc8406b 100644
--- a/fs/bcachefs/chardev.c
+++ b/fs/bcachefs/chardev.c
@@ -360,7 +360,8 @@  static long bch2_ioctl_fsck_offline(struct bch_ioctl_fsck_offline __user *user_a
 	init_waitqueue_head(&thr->output.wait);
 	darray_init(&thr->output2);
 
-	if (copy_from_user(devs, &user_arg->devs[0], sizeof(user_arg->devs[0]) * arg.nr_devs)) {
+	if (copy_from_user(devs, &user_arg->devs[0],
+			   array_size(sizeof(user_arg->devs[0]), arg.nr_devs))) {
 		ret = -EINVAL;
 		goto err;
 	}