]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ipc-mqueue-correct-mq_attr_ok-test-fix
authorAndrew Morton <akpm@linux-foundation.org>
Thu, 3 May 2012 05:44:52 +0000 (15:44 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 3 May 2012 05:47:01 +0000 (15:47 +1000)
add a local to simplify overflow-checking expression

Cc: Doug Ledford <dledford@redhat.com>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
ipc/mqueue.c

index dcceeb4e6b7e0c1a0300fdd75e756dd135a2ac9e..51fe33bae45554c0203a2d7b65213c23645fb8f5 100644 (file)
@@ -672,6 +672,7 @@ static void remove_notification(struct mqueue_inode_info *info)
 static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
 {
        int mq_treesize;
+       unsigned long total_size;
 
        if (attr->mq_maxmsg <= 0 || attr->mq_msgsize <= 0)
                return 0;
@@ -690,9 +691,8 @@ static int mq_attr_ok(struct ipc_namespace *ipc_ns, struct mq_attr *attr)
        mq_treesize = attr->mq_maxmsg * sizeof(struct msg_msg) +
                min_t(unsigned int, attr->mq_maxmsg, MQ_PRIO_MAX) *
                sizeof(struct posix_msg_tree_node);
-       if ((unsigned long)(attr->mq_maxmsg * attr->mq_msgsize +
-                           mq_treesize) <
-           (unsigned long)(attr->mq_maxmsg * attr->mq_msgsize))
+       total_size = attr->mq_maxmsg * attr->mq_msgsize;
+       if (total_size + mq_treesize < total_size)
                return 0;
        return 1;
 }