From 2d7e900e111a4a2775c56f5afac8a0aff2a21e90 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 3 May 2012 15:44:52 +1000 Subject: [PATCH] ipc-mqueue-correct-mq_attr_ok-test-fix add a local to simplify overflow-checking expression Cc: Doug Ledford Cc: Manfred Spraul Cc: Stephen Rothwell Signed-off-by: Andrew Morton --- ipc/mqueue.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index dcceeb4e6b7e..51fe33bae455 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -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; } -- 2.39.5