From: xiongweimin <[email protected]>

Use sizeof(*featurep) instead of sizeof(u64) for better type safety
and consistency with kernel coding style. While sizeof(u64) equals
sizeof(*featurep) on all supported platforms, using sizeof(*featurep)
makes the code more maintainable.

Signed-off-by: Weimin Xiong <[email protected]>
Co-authored-by: Cursor <[email protected]>
---
 drivers/vhost/net.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index c6854cba5..94028598f 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -1777,14 +1777,14 @@ static long vhost_net_ioctl(struct file *f, unsigned 
int ioctl,
                        return -EFAULT;
 
                /* Copy the net features, up to the user-provided buffer size */
-               argp += sizeof(u64);
+               argp += sizeof(*featurep);
                copied = min(count, (u64)VIRTIO_FEATURES_U64S);
                if (copy_to_user(argp, vhost_net_features,
-                                copied * sizeof(u64)))
+                                copied * sizeof(*featurep)))
                        return -EFAULT;
 
                /* Zero the trailing space provided by user-space, if any */
-               if (clear_user(argp, size_mul(count - copied, sizeof(u64))))
+               if (clear_user(argp, size_mul(count - copied, 
sizeof(*featurep))))
                        return -EFAULT;
                return 0;
        case VHOST_SET_FEATURES_ARRAY:
@@ -1792,9 +1792,9 @@ static long vhost_net_ioctl(struct file *f, unsigned int 
ioctl,
                        return -EFAULT;
 
                virtio_features_zero(all_features);
-               argp += sizeof(u64);
+               argp += sizeof(*featurep);
                copied = min(count, (u64)VIRTIO_FEATURES_U64S);
-               if (copy_from_user(all_features, argp, copied * sizeof(u64)))
+               if (copy_from_user(all_features, argp, copied * 
sizeof(*featurep)))
                        return -EFAULT;
 
                /*
-- 
2.43.0


Reply via email to