]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vfio: return -ENOTTY for unsupported device feature
authorAlex Mastro <amastro@fb.com>
Mon, 8 Sep 2025 15:58:40 +0000 (08:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:37:28 +0000 (15:37 -0500)
[ Upstream commit 16df67f2189a71a8310bcebddb87ed569e8352be ]

The two implementers of vfio_device_ops.device_feature,
vfio_cdx_ioctl_feature and vfio_pci_core_ioctl_feature, return
-ENOTTY in the fallthrough case when the feature is unsupported. For
consistency, the base case, vfio_ioctl_device_feature, should do the
same when device_feature == NULL, indicating an implementation has no
feature extensions.

Signed-off-by: Alex Mastro <amastro@fb.com>
Link: https://lore.kernel.org/r/20250908-vfio-enotty-v1-1-4428e1539e2e@fb.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vfio/vfio_main.c

index 5046cae052224e25cef601753b4eab9da9571702..715368076a1fe8146a3fc8ec982a6a5f3cf4a125 100644 (file)
@@ -1251,7 +1251,7 @@ static int vfio_ioctl_device_feature(struct vfio_device *device,
                        feature.argsz - minsz);
        default:
                if (unlikely(!device->ops->device_feature))
-                       return -EINVAL;
+                       return -ENOTTY;
                return device->ops->device_feature(device, feature.flags,
                                                   arg->data,
                                                   feature.argsz - minsz);