From: Lifeng Sun <lifongsun@gmail.com>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: "James R. Van Zandt" <jrv@vanzandt.mv.com>,
blinux-list@redhat.com, Clemens Ladisch <clemens@ladisch.de>,
Massimo Dal Zotto <dz@debian.org>,
Corey Minyard <minyard@acm.org>,
openipmi-developer@lists.sourceforge.net,
Matt Mackall <mpm@selenic.com>,
linux-kernel@vger.kernel.org, Lifeng Sun <lifongsun@gmail.com>
Subject: [PATCH 3/5] char driver: inappropriate ioctl operation should return ENOTTY
Date: Thu, 28 Apr 2011 16:29:20 +0800 [thread overview]
Message-ID: <1303979360-30286-1-git-send-email-lifongsun@gmail.com> (raw)
In-Reply-To: <1303977891-29280-1-git-send-email-lifongsun@gmail.com>
ioctl() calls against a character special file with an inappropriate
ioctl operation are incorrectly returning EINVAL rather than ENOTTY:
[ENOTTY]
Inappropriate I/O control operation.
In dtlk I also fix the error code for failing to call copy_to_user.
Signed-off-by: Lifeng Sun <lifongsun@gmail.com>
---
drivers/char/dtlk.c | 4 ++--
drivers/char/hpet.c | 2 +-
drivers/char/i8k.c | 5 +----
drivers/char/ipmi/ipmi_devintf.c | 3 +++
drivers/char/random.c | 2 +-
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c
index 85156dd..a293431 100644
--- a/drivers/char/dtlk.c
+++ b/drivers/char/dtlk.c
@@ -281,7 +281,7 @@ static long dtlk_ioctl(struct file *file,
sp = dtlk_interrogate();
mutex_unlock(&dtlk_mutex);
if (copy_to_user(argp, sp, sizeof(struct dtlk_settings)))
- return -EINVAL;
+ return -EFAULT;
return 0;
case DTLK_STATUS:
@@ -289,7 +289,7 @@ static long dtlk_ioctl(struct file *file,
return put_user(portval, argp);
default:
- return -EINVAL;
+ return -ENOTTY;
}
}
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index 7066e80..720de66 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -575,7 +575,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
case HPET_IE_ON:
return hpet_ioctl_ieon(devp);
default:
- return -EINVAL;
+ return -ENOTTY;
}
err = 0;
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c
index d72433f..baaa8cc 100644
--- a/drivers/char/i8k.c
+++ b/drivers/char/i8k.c
@@ -317,9 +317,6 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
unsigned char buff[16];
int __user *argp = (int __user *)arg;
- if (!argp)
- return -EINVAL;
-
switch (cmd) {
case I8K_BIOS_VERSION:
val = i8k_get_bios_version();
@@ -370,7 +367,7 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
break;
default:
- return -EINVAL;
+ return -ENOTTY;
}
if (val < 0)
diff --git a/drivers/char/ipmi/ipmi_devintf.c b/drivers/char/ipmi/ipmi_devintf.c
index 2aa3977..e4272f2 100644
--- a/drivers/char/ipmi/ipmi_devintf.c
+++ b/drivers/char/ipmi/ipmi_devintf.c
@@ -624,6 +624,9 @@ static int ipmi_ioctl(struct file *file,
rv = ipmi_set_maintenance_mode(priv->user, mode);
break;
}
+ default:
+ rv = -ENOTTY;
+ break;
}
return rv;
diff --git a/drivers/char/random.c b/drivers/char/random.c
index d4ddeba..40aad1c 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1157,7 +1157,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
rand_initialize();
return 0;
default:
- return -EINVAL;
+ return -ENOTTY;
}
}
--
1.7.5.rc1
next prev parent reply other threads:[~2011-04-28 8:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-27 5:37 [PATCH] Applying inappropriate ioctl operation on socket " Lifeng Sun
2011-04-27 5:58 ` Eric Dumazet
2011-04-27 6:37 ` Lifeng Sun
2011-04-27 6:55 ` Eric Dumazet
2011-04-27 6:57 ` Eric Dumazet
2011-04-27 8:22 ` Lifeng Sun
2011-04-27 9:47 ` Alan Cox
2011-04-27 10:45 ` Eric Dumazet
2011-04-27 11:52 ` Alan Cox
2011-04-27 12:09 ` Alan Cox
2011-04-27 13:54 ` Lifeng Sun
2011-04-28 8:04 ` [PATCH 1/5] networking: inappropriate ioctl operation " Lifeng Sun
2011-04-28 8:28 ` [PATCH 2/5] vfs: inappropriate ioctl operation on pipe/fifo " Lifeng Sun
2011-04-28 8:29 ` Lifeng Sun [this message]
2011-04-28 8:32 ` [PATCH 4/5] char driver: inappropriate ioctl operation " Lifeng Sun
2011-04-28 8:32 ` [PATCH 5/5] drivers/char/applicom.c: ac_ioctl should not always returns 0 Lifeng Sun
2011-05-02 22:41 ` [PATCH 1/5] networking: inappropriate ioctl operation should return ENOTTY David Miller
2011-04-28 8:49 ` [PATCH] Applying inappropriate ioctl operation on socket " Lifeng Sun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303979360-30286-1-git-send-email-lifongsun@gmail.com \
--to=lifongsun@gmail.com \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=blinux-list@redhat.com \
--cc=clemens@ladisch.de \
--cc=dz@debian.org \
--cc=jrv@vanzandt.mv.com \
--cc=linux-kernel@vger.kernel.org \
--cc=minyard@acm.org \
--cc=mpm@selenic.com \
--cc=openipmi-developer@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®