Skip to contentSkip to conversation

dev_ioctl should return -EINVAL for unknown ioctl instead of -ENOTTY

PATCH In review Wang Sheng-Hui 2 participants 3 messages Sep 1, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dev_ioctl should return -EINVAL for unknown ioctl instead of -ENOTTY

The patch is against 3.1-rc3.

---
 net/core/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/core/dev.c +1 -1
index 17d67b5..de6033c 100644
@@ -5092,7 +5092,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		/* Take care of Wireless Extensions */
 		if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
 			return wext_handle_ioctl(net, &ifr, cmd, arg);
-		return -ENOTTY;
+		return -EINVAL;
 	}
 }
 
Signature · 1 line
1.7.1
#1 lore raw
Quoted 12 lines · Wang Sheng-Hui

The patch is against 3.1-rc3.

---
 net/core/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/core/dev.c +0 -0
index 17d67b5..de6033c 100644

net/core/dev.c int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) · line 5098

Quoted 8 lines
net/core/dev.c +1 -1
@@ -5092,7 +5092,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		/* Take care of Wireless Extensions */
 		if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
 			return wext_handle_ioctl(net, &ifr, cmd, arg);
-		return -ENOTTY;
+		return -EINVAL;
 	}
 }
 

Whereas, Linus Torvalds wrote in <[email protected]>:
[...]

Quoted 5 lines

The correct error code for "I don't understand this ioctl" is ENOTTY. The naming may be odd, but you should think of that error value as a "unrecognized ioctl number, you're feeding me random numbers that I don't understand and I assume for historical reasons that you tried to do some tty operation on me".

[...]

(Not that we are consistent about using ENOTTY in networking now.)

Ben.

Signature · 3 lines
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
#2 lore raw
Quoted 30 lines · Ben Hutchings
Quoted 12 lines · Wang Sheng-Hui

The patch is against 3.1-rc3.

---
 net/core/dev.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/core/dev.c +0 -0
index 17d67b5..de6033c 100644

net/core/dev.c int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) · line 5098

Quoted 8 lines
net/core/dev.c +1 -1
@@ -5092,7 +5092,7 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
 		/* Take care of Wireless Extensions */
 		if (cmd >= SIOCIWFIRST && cmd <= SIOCIWLAST)
 			return wext_handle_ioctl(net, &ifr, cmd, arg);
-		return -ENOTTY;
+		return -EINVAL;
 	}
 }
 

Whereas, Linus Torvalds wrote in <[email protected]>:
[...]

Quoted 5 lines

The correct error code for "I don't understand this ioctl" is ENOTTY. The naming may be odd, but you should think of that error value as a "unrecognized ioctl number, you're feeding me random numbers that I don't understand and I assume for historical reasons that you tried to do some tty operation on me".

Quoted 6 lines

[...]

(Not that we are consistent about using ENOTTY in networking now.)

Ben.

Got it. Thanks.