Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752814AbbGBIhM (ORCPT ); Thu, 2 Jul 2015 04:37:12 -0400 Received: from mail-lb0-f170.google.com ([209.85.217.170]:34975 "EHLO mail-lb0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751106AbbGBIhH (ORCPT ); Thu, 2 Jul 2015 04:37:07 -0400 MIME-Version: 1.0 In-Reply-To: <1435497454-10464-5-git-send-email-sergei@s15v.net> References: <1435497454-10464-1-git-send-email-sergei@s15v.net> <1435497454-10464-5-git-send-email-sergei@s15v.net> Date: Thu, 2 Jul 2015 10:37:05 +0200 Message-ID: Subject: Re: [PATCH RFC 4/5] kdbus: handle WARN_ON cases properly when decrementing quota From: David Herrmann To: Sergei Zviagintsev Cc: Greg Kroah-Hartman , Daniel Mack , David Herrmann , Djalal Harouni , linux-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1490 Lines: 49 Hi On Sun, Jun 28, 2015 at 3:17 PM, Sergei Zviagintsev wrote: > If we spotted inconsistency, fix it by setting values to zero. Why? I prefer doing nothing and just bailing out on programming errors. Setting it to 0 just complicates debugging and drops possibly useful information ('what was the counter value at that time?'). Thanks David > Signed-off-by: Sergei Zviagintsev > --- > ipc/kdbus/connection.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/ipc/kdbus/connection.c b/ipc/kdbus/connection.c > index 1d44e280eff0..12e32de310f5 100644 > --- a/ipc/kdbus/connection.c > +++ b/ipc/kdbus/connection.c > @@ -742,9 +742,15 @@ void kdbus_conn_quota_dec(struct kdbus_conn *c, struct kdbus_user *u, > > if (!WARN_ON(quota->msgs == 0)) > --quota->msgs; > - if (!WARN_ON(quota->memory < memory)) > + > + if (WARN_ON(quota->memory < memory)) > + quota->memory = 0; > + else > quota->memory -= memory; > - if (!WARN_ON(quota->fds < fds)) > + > + if (WARN_ON(quota->fds < fds)) > + quota->fds = 0; > + else > quota->fds -= fds; > } > > -- > 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/