lkml.org 
[lkml]   [2015]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH RFC 4/5] kdbus: handle WARN_ON cases properly when decrementing quota
From
Hi

On Sun, Jun 28, 2015 at 3:17 PM, Sergei Zviagintsev <sergei@s15v.net> 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 <sergei@s15v.net>
> ---
> 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
>


\
 
 \ /
  Last update: 2015-07-02 11:01    [W:0.133 / U:1.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site