aboutsummaryrefslogtreecommitdiffstats
path: root/ipc/mqueue.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-08-28 12:52:22 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-09-26 22:20:08 -0400
commit2903ff019b346ab8d36ebbf54853c3aaf6590608 (patch)
tree962d94054765bb37bc00e977c3036e65c5fd91fe /ipc/mqueue.c
parenta5b470ba06aa3f96999ede5feba178df6bdb134a (diff)
switch simple cases of fget_light to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc/mqueue.c')
-rw-r--r--ipc/mqueue.c84
1 files changed, 41 insertions, 43 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 5db1b69500fd..6d255e535d03 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -944,7 +944,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
944 size_t, msg_len, unsigned int, msg_prio, 944 size_t, msg_len, unsigned int, msg_prio,
945 const struct timespec __user *, u_abs_timeout) 945 const struct timespec __user *, u_abs_timeout)
946{ 946{
947 struct file *filp; 947 struct fd f;
948 struct inode *inode; 948 struct inode *inode;
949 struct ext_wait_queue wait; 949 struct ext_wait_queue wait;
950 struct ext_wait_queue *receiver; 950 struct ext_wait_queue *receiver;
@@ -953,7 +953,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
953 ktime_t expires, *timeout = NULL; 953 ktime_t expires, *timeout = NULL;
954 struct timespec ts; 954 struct timespec ts;
955 struct posix_msg_tree_node *new_leaf = NULL; 955 struct posix_msg_tree_node *new_leaf = NULL;
956 int ret = 0, fput_needed; 956 int ret = 0;
957 957
958 if (u_abs_timeout) { 958 if (u_abs_timeout) {
959 int res = prepare_timeout(u_abs_timeout, &expires, &ts); 959 int res = prepare_timeout(u_abs_timeout, &expires, &ts);
@@ -967,21 +967,21 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
967 967
968 audit_mq_sendrecv(mqdes, msg_len, msg_prio, timeout ? &ts : NULL); 968 audit_mq_sendrecv(mqdes, msg_len, msg_prio, timeout ? &ts : NULL);
969 969
970 filp = fget_light(mqdes, &fput_needed); 970 f = fdget(mqdes);
971 if (unlikely(!filp)) { 971 if (unlikely(!f.file)) {
972 ret = -EBADF; 972 ret = -EBADF;
973 goto out; 973 goto out;
974 } 974 }
975 975
976 inode = filp->f_path.dentry->d_inode; 976 inode = f.file->f_path.dentry->d_inode;
977 if (unlikely(filp->f_op != &mqueue_file_operations)) { 977 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
978 ret = -EBADF; 978 ret = -EBADF;
979 goto out_fput; 979 goto out_fput;
980 } 980 }
981 info = MQUEUE_I(inode); 981 info = MQUEUE_I(inode);
982 audit_inode(NULL, filp->f_path.dentry); 982 audit_inode(NULL, f.file->f_path.dentry);
983 983
984 if (unlikely(!(filp->f_mode & FMODE_WRITE))) { 984 if (unlikely(!(f.file->f_mode & FMODE_WRITE))) {
985 ret = -EBADF; 985 ret = -EBADF;
986 goto out_fput; 986 goto out_fput;
987 } 987 }
@@ -1023,7 +1023,7 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
1023 } 1023 }
1024 1024
1025 if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) { 1025 if (info->attr.mq_curmsgs == info->attr.mq_maxmsg) {
1026 if (filp->f_flags & O_NONBLOCK) { 1026 if (f.file->f_flags & O_NONBLOCK) {
1027 ret = -EAGAIN; 1027 ret = -EAGAIN;
1028 } else { 1028 } else {
1029 wait.task = current; 1029 wait.task = current;
@@ -1056,7 +1056,7 @@ out_free:
1056 if (ret) 1056 if (ret)
1057 free_msg(msg_ptr); 1057 free_msg(msg_ptr);
1058out_fput: 1058out_fput:
1059 fput_light(filp, fput_needed); 1059 fdput(f);
1060out: 1060out:
1061 return ret; 1061 return ret;
1062} 1062}
@@ -1067,14 +1067,13 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1067{ 1067{
1068 ssize_t ret; 1068 ssize_t ret;
1069 struct msg_msg *msg_ptr; 1069 struct msg_msg *msg_ptr;
1070 struct file *filp; 1070 struct fd f;
1071 struct inode *inode; 1071 struct inode *inode;
1072 struct mqueue_inode_info *info; 1072 struct mqueue_inode_info *info;
1073 struct ext_wait_queue wait; 1073 struct ext_wait_queue wait;
1074 ktime_t expires, *timeout = NULL; 1074 ktime_t expires, *timeout = NULL;
1075 struct timespec ts; 1075 struct timespec ts;
1076 struct posix_msg_tree_node *new_leaf = NULL; 1076 struct posix_msg_tree_node *new_leaf = NULL;
1077 int fput_needed;
1078 1077
1079 if (u_abs_timeout) { 1078 if (u_abs_timeout) {
1080 int res = prepare_timeout(u_abs_timeout, &expires, &ts); 1079 int res = prepare_timeout(u_abs_timeout, &expires, &ts);
@@ -1085,21 +1084,21 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1085 1084
1086 audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL); 1085 audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL);
1087 1086
1088 filp = fget_light(mqdes, &fput_needed); 1087 f = fdget(mqdes);
1089 if (unlikely(!filp)) { 1088 if (unlikely(!f.file)) {
1090 ret = -EBADF; 1089 ret = -EBADF;
1091 goto out; 1090 goto out;
1092 } 1091 }
1093 1092
1094 inode = filp->f_path.dentry->d_inode; 1093 inode = f.file->f_path.dentry->d_inode;
1095 if (unlikely(filp->f_op != &mqueue_file_operations)) { 1094 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1096 ret = -EBADF; 1095 ret = -EBADF;
1097 goto out_fput; 1096 goto out_fput;
1098 } 1097 }
1099 info = MQUEUE_I(inode); 1098 info = MQUEUE_I(inode);
1100 audit_inode(NULL, filp->f_path.dentry); 1099 audit_inode(NULL, f.file->f_path.dentry);
1101 1100
1102 if (unlikely(!(filp->f_mode & FMODE_READ))) { 1101 if (unlikely(!(f.file->f_mode & FMODE_READ))) {
1103 ret = -EBADF; 1102 ret = -EBADF;
1104 goto out_fput; 1103 goto out_fput;
1105 } 1104 }
@@ -1131,7 +1130,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1131 } 1130 }
1132 1131
1133 if (info->attr.mq_curmsgs == 0) { 1132 if (info->attr.mq_curmsgs == 0) {
1134 if (filp->f_flags & O_NONBLOCK) { 1133 if (f.file->f_flags & O_NONBLOCK) {
1135 spin_unlock(&info->lock); 1134 spin_unlock(&info->lock);
1136 ret = -EAGAIN; 1135 ret = -EAGAIN;
1137 } else { 1136 } else {
@@ -1161,7 +1160,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
1161 free_msg(msg_ptr); 1160 free_msg(msg_ptr);
1162 } 1161 }
1163out_fput: 1162out_fput:
1164 fput_light(filp, fput_needed); 1163 fdput(f);
1165out: 1164out:
1166 return ret; 1165 return ret;
1167} 1166}
@@ -1174,8 +1173,8 @@ out:
1174SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, 1173SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
1175 const struct sigevent __user *, u_notification) 1174 const struct sigevent __user *, u_notification)
1176{ 1175{
1177 int ret, fput_needed; 1176 int ret;
1178 struct file *filp; 1177 struct fd f;
1179 struct sock *sock; 1178 struct sock *sock;
1180 struct inode *inode; 1179 struct inode *inode;
1181 struct sigevent notification; 1180 struct sigevent notification;
@@ -1221,13 +1220,13 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes,
1221 skb_put(nc, NOTIFY_COOKIE_LEN); 1220 skb_put(nc, NOTIFY_COOKIE_LEN);
1222 /* and attach it to the socket */ 1221 /* and attach it to the socket */
1223retry: 1222retry:
1224 filp = fget_light(notification.sigev_signo, &fput_needed); 1223 f = fdget(notification.sigev_signo);
1225 if (!filp) { 1224 if (!f.file) {
1226 ret = -EBADF; 1225 ret = -EBADF;
1227 goto out; 1226 goto out;
1228 } 1227 }
1229 sock = netlink_getsockbyfilp(filp); 1228 sock = netlink_getsockbyfilp(f.file);
1230 fput_light(filp, fput_needed); 1229 fdput(f);
1231 if (IS_ERR(sock)) { 1230 if (IS_ERR(sock)) {
1232 ret = PTR_ERR(sock); 1231 ret = PTR_ERR(sock);
1233 sock = NULL; 1232 sock = NULL;
@@ -1246,14 +1245,14 @@ retry:
1246 } 1245 }
1247 } 1246 }
1248 1247
1249 filp = fget_light(mqdes, &fput_needed); 1248 f = fdget(mqdes);
1250 if (!filp) { 1249 if (!f.file) {
1251 ret = -EBADF; 1250 ret = -EBADF;
1252 goto out; 1251 goto out;
1253 } 1252 }
1254 1253
1255 inode = filp->f_path.dentry->d_inode; 1254 inode = f.file->f_path.dentry->d_inode;
1256 if (unlikely(filp->f_op != &mqueue_file_operations)) { 1255 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1257 ret = -EBADF; 1256 ret = -EBADF;
1258 goto out_fput; 1257 goto out_fput;
1259 } 1258 }
@@ -1293,7 +1292,7 @@ retry:
1293 } 1292 }
1294 spin_unlock(&info->lock); 1293 spin_unlock(&info->lock);
1295out_fput: 1294out_fput:
1296 fput_light(filp, fput_needed); 1295 fdput(f);
1297out: 1296out:
1298 if (sock) { 1297 if (sock) {
1299 netlink_detachskb(sock, nc); 1298 netlink_detachskb(sock, nc);
@@ -1309,8 +1308,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1309{ 1308{
1310 int ret; 1309 int ret;
1311 struct mq_attr mqstat, omqstat; 1310 struct mq_attr mqstat, omqstat;
1312 int fput_needed; 1311 struct fd f;
1313 struct file *filp;
1314 struct inode *inode; 1312 struct inode *inode;
1315 struct mqueue_inode_info *info; 1313 struct mqueue_inode_info *info;
1316 1314
@@ -1321,14 +1319,14 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1321 return -EINVAL; 1319 return -EINVAL;
1322 } 1320 }
1323 1321
1324 filp = fget_light(mqdes, &fput_needed); 1322 f = fdget(mqdes);
1325 if (!filp) { 1323 if (!f.file) {
1326 ret = -EBADF; 1324 ret = -EBADF;
1327 goto out; 1325 goto out;
1328 } 1326 }
1329 1327
1330 inode = filp->f_path.dentry->d_inode; 1328 inode = f.file->f_path.dentry->d_inode;
1331 if (unlikely(filp->f_op != &mqueue_file_operations)) { 1329 if (unlikely(f.file->f_op != &mqueue_file_operations)) {
1332 ret = -EBADF; 1330 ret = -EBADF;
1333 goto out_fput; 1331 goto out_fput;
1334 } 1332 }
@@ -1337,15 +1335,15 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1337 spin_lock(&info->lock); 1335 spin_lock(&info->lock);
1338 1336
1339 omqstat = info->attr; 1337 omqstat = info->attr;
1340 omqstat.mq_flags = filp->f_flags & O_NONBLOCK; 1338 omqstat.mq_flags = f.file->f_flags & O_NONBLOCK;
1341 if (u_mqstat) { 1339 if (u_mqstat) {
1342 audit_mq_getsetattr(mqdes, &mqstat); 1340 audit_mq_getsetattr(mqdes, &mqstat);
1343 spin_lock(&filp->f_lock); 1341 spin_lock(&f.file->f_lock);
1344 if (mqstat.mq_flags & O_NONBLOCK) 1342 if (mqstat.mq_flags & O_NONBLOCK)
1345 filp->f_flags |= O_NONBLOCK; 1343 f.file->f_flags |= O_NONBLOCK;
1346 else 1344 else
1347 filp->f_flags &= ~O_NONBLOCK; 1345 f.file->f_flags &= ~O_NONBLOCK;
1348 spin_unlock(&filp->f_lock); 1346 spin_unlock(&f.file->f_lock);
1349 1347
1350 inode->i_atime = inode->i_ctime = CURRENT_TIME; 1348 inode->i_atime = inode->i_ctime = CURRENT_TIME;
1351 } 1349 }
@@ -1358,7 +1356,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes,
1358 ret = -EFAULT; 1356 ret = -EFAULT;
1359 1357
1360out_fput: 1358out_fput:
1361 fput_light(filp, fput_needed); 1359 fdput(f);
1362out: 1360out:
1363 return ret; 1361 return ret;
1364} 1362}