Re: [PATCH] sysctl: Use BUG_ON instead of BUG

From: Andrew Morton
Date: Tue Sep 04 2012 - 19:18:49 EST


On Mon, 3 Sep 2012 09:00:25 +0530
Prasad Joshi <prasadjoshi.linux@xxxxxxxxx> wrote:

> The use of if (!head) BUG(); can be replaced with single line
> BUG_ON(!head).
>
> Signed-off-by: Prasad Joshi <prasadjoshi.linux@xxxxxxxxx>
> ---
> fs/proc/proc_sysctl.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index dfafeb2..63bdfa0 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -266,8 +266,7 @@ void sysctl_head_put(struct ctl_table_header *head)
>
> static struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
> {
> - if (!head)
> - BUG();
> + BUG_ON(!head);
> spin_lock(&sysctl_lock);
> if (!use_table(head))
> head = ERR_PTR(-ENOENT);

We could just remove the check altogether. The resulting NULL pointer
deref oops in use_table() will give us the same info as that BUG().

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/