aboutsummaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2013-01-04 18:34:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-01-04 19:11:45 -0500
commit85398aa8de1d68f44ff1b5d0ed9ceb2b0c51ce49 (patch)
tree945dba3d9fdb7a607134955b50cdeedf6520d2dd /ipc
parent3a665531a3b7c2ad2c87903b24646be6916340e4 (diff)
ipc: simplify free_copy() call
Passing and checking of msgflg to free_copy() is redundant. This patch sets copy to NULL on declaration instead and checks for non-NULL in free_copy(). Note: in case of copy allocation failure, error is returned immediately. So no need to check for IS_ERR() in free_copy(). Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: James Morris <jmorris@namei.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/msg.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index d20ffc7d3f24..7a20536c3a50 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -797,15 +797,17 @@ static inline struct msg_msg *prepare_copy(void __user *buf, size_t bufsz,
797 return copy; 797 return copy;
798} 798}
799 799
800static inline void free_copy(int msgflg, struct msg_msg *copy) 800static inline void free_copy(struct msg_msg *copy)
801{ 801{
802 if (msgflg & MSG_COPY) 802 if (copy)
803 free_msg(copy); 803 free_msg(copy);
804} 804}
805#else 805#else
806#define free_copy(msgflg, copy) do {} while (0)
807#define prepare_copy(buf, sz, msgflg, msgtyp, copy_nr) ERR_PTR(-ENOSYS) 806#define prepare_copy(buf, sz, msgflg, msgtyp, copy_nr) ERR_PTR(-ENOSYS)
808#define fill_copy(copy_nr, msg_nr, msg, copy) NULL 807#define fill_copy(copy_nr, msg_nr, msg, copy) NULL
808static inline void free_copy(struct msg_msg *copy)
809{
810}
809#endif 811#endif
810 812
811long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp, 813long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
@@ -816,7 +818,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
816 struct msg_msg *msg; 818 struct msg_msg *msg;
817 int mode; 819 int mode;
818 struct ipc_namespace *ns; 820 struct ipc_namespace *ns;
819 struct msg_msg *copy; 821 struct msg_msg *copy = NULL;
820 unsigned long __maybe_unused copy_number; 822 unsigned long __maybe_unused copy_number;
821 823
822 if (msqid < 0 || (long) bufsz < 0) 824 if (msqid < 0 || (long) bufsz < 0)
@@ -831,7 +833,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
831 833
832 msq = msg_lock_check(ns, msqid); 834 msq = msg_lock_check(ns, msqid);
833 if (IS_ERR(msq)) { 835 if (IS_ERR(msq)) {
834 free_copy(msgflg, copy); 836 free_copy(copy);
835 return PTR_ERR(msq); 837 return PTR_ERR(msq);
836 } 838 }
837 839
@@ -965,7 +967,7 @@ out_unlock:
965 } 967 }
966 } 968 }
967 if (IS_ERR(msg)) { 969 if (IS_ERR(msg)) {
968 free_copy(msgflg, copy); 970 free_copy(copy);
969 return PTR_ERR(msg); 971 return PTR_ERR(msg);
970 } 972 }
971 973