Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752719AbbF1N27 (ORCPT ); Sun, 28 Jun 2015 09:28:59 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:54168 "EHLO out3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752745AbbF1N16 (ORCPT ); Sun, 28 Jun 2015 09:27:58 -0400 X-Sasl-enc: NsBHGjv5MVF2gYYfmKrL8JKYxII0sAOo4aJ6yFb/Y6Lq 1435497485 From: Sergei Zviagintsev To: Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni Cc: linux-kernel@vger.kernel.org, Sergei Zviagintsev Subject: [PATCH RFC 3/5] kdbus: do explicit overflow check in kdbus_conn_quota_inc() Date: Sun, 28 Jun 2015 16:17:32 +0300 Message-Id: <1435497454-10464-4-git-send-email-sergei@s15v.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1435497454-10464-1-git-send-email-sergei@s15v.net> References: <1435497454-10464-1-git-send-email-sergei@s15v.net> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1051 Lines: 33 Replace the use of max() with explicit and obvious overflow check. Signed-off-by: Sergei Zviagintsev --- ipc/kdbus/connection.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c index af044f93c14f..1d44e280eff0 100644 --- a/ipc/kdbus/connection.c +++ b/ipc/kdbus/connection.c @@ -668,9 +668,11 @@ int kdbus_conn_quota_inc(struct kdbus_conn *c, struct kdbus_user *u, id = u ? u->id : KDBUS_USER_KERNEL_ID; if (id >= c->n_quota) { - unsigned int users; + unsigned int users = KDBUS_ALIGN8(id) + 8; + + if (users < id) /* overflow */ + users = id; - users = max(KDBUS_ALIGN8(id) + 8, id); quota = krealloc(c->quota, users * sizeof(*quota), GFP_KERNEL | __GFP_ZERO); if (!quota) -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/