if (f_handle.handle_bytes > MAX_HANDLE_SZ)
                return -EINVAL;
 
-       handle = kzalloc(sizeof(struct file_handle) + f_handle.handle_bytes,
+       handle = kzalloc(struct_size(handle, f_handle, f_handle.handle_bytes),
                         GFP_KERNEL);
        if (!handle)
                return -ENOMEM;
        /* copy the mount id */
        if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
            copy_to_user(ufh, handle,
-                        sizeof(struct file_handle) + handle_bytes))
+                        struct_size(handle, f_handle, handle_bytes)))
                retval = -EFAULT;
        kfree(handle);
        return retval;
                retval = -EINVAL;
                goto out_err;
        }
-       handle = kmalloc(sizeof(struct file_handle) + f_handle.handle_bytes,
+       handle = kmalloc(struct_size(handle, f_handle, f_handle.handle_bytes),
                         GFP_KERNEL);
        if (!handle) {
                retval = -ENOMEM;
 
        __u32 handle_bytes;
        int handle_type;
        /* file identifier */
-       unsigned char f_handle[];
+       unsigned char f_handle[] __counted_by(handle_bytes);
 };
 
 static inline struct file *get_file(struct file *f)