diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-08-27 03:11:34 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-26 21:10:09 -0400 |
commit | 515e0d6634086d61ae846f0e8785b6f0220f3422 (patch) | |
tree | b099c7ec3b4c075851a70e56c4683e412ca3492e /ipc | |
parent | bdbf69437a5ae6f820a6d3aa8c6e3c3ce7e6e05f (diff) |
switch mqueue syscalls to fget_light()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/mqueue.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 9a08acc9e649..5db1b69500fd 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -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; | 956 | int ret = 0, fput_needed; |
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,7 +967,7 @@ 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(mqdes); | 970 | filp = fget_light(mqdes, &fput_needed); |
971 | if (unlikely(!filp)) { | 971 | if (unlikely(!filp)) { |
972 | ret = -EBADF; | 972 | ret = -EBADF; |
973 | goto out; | 973 | goto out; |
@@ -1056,7 +1056,7 @@ out_free: | |||
1056 | if (ret) | 1056 | if (ret) |
1057 | free_msg(msg_ptr); | 1057 | free_msg(msg_ptr); |
1058 | out_fput: | 1058 | out_fput: |
1059 | fput(filp); | 1059 | fput_light(filp, fput_needed); |
1060 | out: | 1060 | out: |
1061 | return ret; | 1061 | return ret; |
1062 | } | 1062 | } |
@@ -1074,6 +1074,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, | |||
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; | ||
1077 | 1078 | ||
1078 | if (u_abs_timeout) { | 1079 | if (u_abs_timeout) { |
1079 | int res = prepare_timeout(u_abs_timeout, &expires, &ts); | 1080 | int res = prepare_timeout(u_abs_timeout, &expires, &ts); |
@@ -1084,7 +1085,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, | |||
1084 | 1085 | ||
1085 | audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL); | 1086 | audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL); |
1086 | 1087 | ||
1087 | filp = fget(mqdes); | 1088 | filp = fget_light(mqdes, &fput_needed); |
1088 | if (unlikely(!filp)) { | 1089 | if (unlikely(!filp)) { |
1089 | ret = -EBADF; | 1090 | ret = -EBADF; |
1090 | goto out; | 1091 | goto out; |
@@ -1160,7 +1161,7 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr, | |||
1160 | free_msg(msg_ptr); | 1161 | free_msg(msg_ptr); |
1161 | } | 1162 | } |
1162 | out_fput: | 1163 | out_fput: |
1163 | fput(filp); | 1164 | fput_light(filp, fput_needed); |
1164 | out: | 1165 | out: |
1165 | return ret; | 1166 | return ret; |
1166 | } | 1167 | } |
@@ -1173,7 +1174,7 @@ out: | |||
1173 | SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, | 1174 | SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, |
1174 | const struct sigevent __user *, u_notification) | 1175 | const struct sigevent __user *, u_notification) |
1175 | { | 1176 | { |
1176 | int ret; | 1177 | int ret, fput_needed; |
1177 | struct file *filp; | 1178 | struct file *filp; |
1178 | struct sock *sock; | 1179 | struct sock *sock; |
1179 | struct inode *inode; | 1180 | struct inode *inode; |
@@ -1220,13 +1221,13 @@ SYSCALL_DEFINE2(mq_notify, mqd_t, mqdes, | |||
1220 | skb_put(nc, NOTIFY_COOKIE_LEN); | 1221 | skb_put(nc, NOTIFY_COOKIE_LEN); |
1221 | /* and attach it to the socket */ | 1222 | /* and attach it to the socket */ |
1222 | retry: | 1223 | retry: |
1223 | filp = fget(notification.sigev_signo); | 1224 | filp = fget_light(notification.sigev_signo, &fput_needed); |
1224 | if (!filp) { | 1225 | if (!filp) { |
1225 | ret = -EBADF; | 1226 | ret = -EBADF; |
1226 | goto out; | 1227 | goto out; |
1227 | } | 1228 | } |
1228 | sock = netlink_getsockbyfilp(filp); | 1229 | sock = netlink_getsockbyfilp(filp); |
1229 | fput(filp); | 1230 | fput_light(filp, fput_needed); |
1230 | if (IS_ERR(sock)) { | 1231 | if (IS_ERR(sock)) { |
1231 | ret = PTR_ERR(sock); | 1232 | ret = PTR_ERR(sock); |
1232 | sock = NULL; | 1233 | sock = NULL; |
@@ -1245,7 +1246,7 @@ retry: | |||
1245 | } | 1246 | } |
1246 | } | 1247 | } |
1247 | 1248 | ||
1248 | filp = fget(mqdes); | 1249 | filp = fget_light(mqdes, &fput_needed); |
1249 | if (!filp) { | 1250 | if (!filp) { |
1250 | ret = -EBADF; | 1251 | ret = -EBADF; |
1251 | goto out; | 1252 | goto out; |
@@ -1292,7 +1293,7 @@ retry: | |||
1292 | } | 1293 | } |
1293 | spin_unlock(&info->lock); | 1294 | spin_unlock(&info->lock); |
1294 | out_fput: | 1295 | out_fput: |
1295 | fput(filp); | 1296 | fput_light(filp, fput_needed); |
1296 | out: | 1297 | out: |
1297 | if (sock) { | 1298 | if (sock) { |
1298 | netlink_detachskb(sock, nc); | 1299 | netlink_detachskb(sock, nc); |
@@ -1308,6 +1309,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, | |||
1308 | { | 1309 | { |
1309 | int ret; | 1310 | int ret; |
1310 | struct mq_attr mqstat, omqstat; | 1311 | struct mq_attr mqstat, omqstat; |
1312 | int fput_needed; | ||
1311 | struct file *filp; | 1313 | struct file *filp; |
1312 | struct inode *inode; | 1314 | struct inode *inode; |
1313 | struct mqueue_inode_info *info; | 1315 | struct mqueue_inode_info *info; |
@@ -1319,7 +1321,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, | |||
1319 | return -EINVAL; | 1321 | return -EINVAL; |
1320 | } | 1322 | } |
1321 | 1323 | ||
1322 | filp = fget(mqdes); | 1324 | filp = fget_light(mqdes, &fput_needed); |
1323 | if (!filp) { | 1325 | if (!filp) { |
1324 | ret = -EBADF; | 1326 | ret = -EBADF; |
1325 | goto out; | 1327 | goto out; |
@@ -1356,7 +1358,7 @@ SYSCALL_DEFINE3(mq_getsetattr, mqd_t, mqdes, | |||
1356 | ret = -EFAULT; | 1358 | ret = -EFAULT; |
1357 | 1359 | ||
1358 | out_fput: | 1360 | out_fput: |
1359 | fput(filp); | 1361 | fput_light(filp, fput_needed); |
1360 | out: | 1362 | out: |
1361 | return ret; | 1363 | return ret; |
1362 | } | 1364 | } |