rfkill: return ENOTTY on invalid ioctl
authorThomas Weißschuh <linux@weissschuh.net>
Wed, 1 Nov 2023 19:41:38 +0000 (20:41 +0100)
committerJohannes Berg <johannes.berg@intel.com>
Fri, 24 Nov 2023 19:03:59 +0000 (20:03 +0100)
For unknown ioctls the correct error is
ENOTTY "Inappropriate ioctl for device".

ENOSYS as returned before should only be used to
indicate that a syscall is not available at all.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Link: https://lore.kernel.org/r/20231101-rfkill-ioctl-enosys-v1-1-5bf374fabffe@weissschuh.net
[in theory this breaks userspace API, but it was discussed and
 researched, and nothing found relying on the current behaviour]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/rfkill/core.c

index 14cc8fe8584bd1ed595a1f6918ebf9dd10364ac8..c3feb4f49d09ca375f718267adf9e31ab1216b3a 100644 (file)
@@ -1351,11 +1351,11 @@ static long rfkill_fop_ioctl(struct file *file, unsigned int cmd,
                             unsigned long arg)
 {
        struct rfkill_data *data = file->private_data;
-       int ret = -ENOSYS;
+       int ret = -ENOTTY;
        u32 size;
 
        if (_IOC_TYPE(cmd) != RFKILL_IOC_MAGIC)
-               return -ENOSYS;
+               return -ENOTTY;
 
        mutex_lock(&data->mtx);
        switch (_IOC_NR(cmd)) {