]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/i915/gvt: Improve intel_vgpu_ioctl hdr error handling
authorJonathan Cavitt <jonathan.cavitt@intel.com>
Tue, 23 Sep 2025 21:23:33 +0000 (21:23 +0000)
committerAndi Shyti <andi.shyti@linux.intel.com>
Thu, 25 Sep 2025 22:27:54 +0000 (00:27 +0200)
commit22a2f2e35f9c08c8572003d1e6d3f0e9ab968837
tree9c13bd5ff19b2b51d472bcd7419da89f9ceaaf93
parent69b4d367fff6d311da6e3ce1b8b34b3e37b59b5a
drm/i915/gvt: Improve intel_vgpu_ioctl hdr error handling

Add error handling for the following VFIO_DEVICE_SET_IRQS cases with
respect to the hdr struct:

- More than one VFIO_IRQ_DATA_TYPE_MASK flag is set in hdr.flags
- More than one VFIO_IRQ_ACTION_TYPE_MASK flag is set in hdr.flags
- hdr.count is not specified

Note that since hdr.count != 0, data_size != 0 is guaranteed unless
vfio_set_irqs_validate_and_prepare fails and returns an error.  So, we
no longer need to check data_size before running memdup_user because
checking the return value of the function is sufficient.

v2: Use correct name for mask

v3: Use is_power_of_2 over hweight32 as it's more efficient (Andi)

Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: Andi Shyti <andi.shyti@linux.intel.com>
Reviewed-by: Zhenyu Wang <zhenyuw.linux@gmail.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Andi Shyti <andi.shyti@linux.intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Link: https://lore.kernel.org/r/20250923212332.112137-2-jonathan.cavitt@intel.com
drivers/gpu/drm/i915/gvt/kvmgt.c