diff options
author | André Goddard Rosa <andre.goddard@gmail.com> | 2010-02-23 02:04:23 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2010-03-03 14:47:59 -0500 |
commit | c8308b1c91056b09e96d40dbde4880ea685c377e (patch) | |
tree | bfaf1f636ef161f5410cd8ba8a1e3b023fd0c33b | |
parent | 4294a8eedb17bbc45e1e7447c2a4d05332943248 (diff) |
mqueue: remove unneeded info->messages initialization
... and abort earlier if we couldn't allocate the message pointers array,
avoiding the u->mq_bytes accounting logic.
It reduces code size:
text data bss dec hex filename
9949 72 16 10037 2735 ipc/mqueue-BEFORE.o
9941 72 16 10029 272d ipc/mqueue-AFTER.o
Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | ipc/mqueue.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 04985a7256c2..3660c334ee6b 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c | |||
@@ -134,7 +134,6 @@ static struct inode *mqueue_get_inode(struct super_block *sb, | |||
134 | init_waitqueue_head(&info->wait_q); | 134 | init_waitqueue_head(&info->wait_q); |
135 | INIT_LIST_HEAD(&info->e_wait_q[0].list); | 135 | INIT_LIST_HEAD(&info->e_wait_q[0].list); |
136 | INIT_LIST_HEAD(&info->e_wait_q[1].list); | 136 | INIT_LIST_HEAD(&info->e_wait_q[1].list); |
137 | info->messages = NULL; | ||
138 | info->notify_owner = NULL; | 137 | info->notify_owner = NULL; |
139 | info->qsize = 0; | 138 | info->qsize = 0; |
140 | info->user = NULL; /* set when all is ok */ | 139 | info->user = NULL; /* set when all is ok */ |
@@ -146,6 +145,10 @@ static struct inode *mqueue_get_inode(struct super_block *sb, | |||
146 | info->attr.mq_msgsize = attr->mq_msgsize; | 145 | info->attr.mq_msgsize = attr->mq_msgsize; |
147 | } | 146 | } |
148 | mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *); | 147 | mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *); |
148 | info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL); | ||
149 | if (!info->messages) | ||
150 | goto out_inode; | ||
151 | |||
149 | mq_bytes = (mq_msg_tblsz + | 152 | mq_bytes = (mq_msg_tblsz + |
150 | (info->attr.mq_maxmsg * info->attr.mq_msgsize)); | 153 | (info->attr.mq_maxmsg * info->attr.mq_msgsize)); |
151 | 154 | ||
@@ -154,18 +157,12 @@ static struct inode *mqueue_get_inode(struct super_block *sb, | |||
154 | u->mq_bytes + mq_bytes > | 157 | u->mq_bytes + mq_bytes > |
155 | p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) { | 158 | p->signal->rlim[RLIMIT_MSGQUEUE].rlim_cur) { |
156 | spin_unlock(&mq_lock); | 159 | spin_unlock(&mq_lock); |
160 | kfree(info->messages); | ||
157 | goto out_inode; | 161 | goto out_inode; |
158 | } | 162 | } |
159 | u->mq_bytes += mq_bytes; | 163 | u->mq_bytes += mq_bytes; |
160 | spin_unlock(&mq_lock); | 164 | spin_unlock(&mq_lock); |
161 | 165 | ||
162 | info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL); | ||
163 | if (!info->messages) { | ||
164 | spin_lock(&mq_lock); | ||
165 | u->mq_bytes -= mq_bytes; | ||
166 | spin_unlock(&mq_lock); | ||
167 | goto out_inode; | ||
168 | } | ||
169 | /* all is ok */ | 166 | /* all is ok */ |
170 | info->user = get_uid(u); | 167 | info->user = get_uid(u); |
171 | } else if (S_ISDIR(mode)) { | 168 | } else if (S_ISDIR(mode)) { |