Re: [PATCH] kernel/groups.c: consider about NULL for 'group_info' inall related extern functions

From: Tejun Heo
Date: Mon Sep 23 2013 - 11:06:35 EST


Hello,

(I have no idea about this but Andrew tagged me, probably thinking it
was related to cgroups, so here it goes ;)

On Tue, Aug 20, 2013 at 11:01:14AM +0800, Chen Gang wrote:
> groups_alloc() can return NULL for 'group_info', also group_search()
> already considers about NULL for 'group_info', so can assume the caller
> has right to use all related extern functions when 'group_info' is NULL.
>
> For groups_free(), need check NULL to match groups_alloc(), just like
> kmalloc/free().

While it is somewhat customary to make free routines handle NULL
inputs, the convention isn't a very strong one and given that the
above change doesn't actually benefit any of the existing use cases,
it seems gratuituous.

> For set_groups(), can allow the caller to set NULL parameter to new
> 'cred'.
>
> For system call getgroups(), if 'cred->group_info' is NULL, need return
> the related error code (no related data), also need change the related
> man page ("man 2 getgroups") to complete the return value.

How can cred->group_info be NULL? Can you please describe what issue
this patch is trying to solve / improve? The patch description
explains what's being changed but doesn't really offer why such
changes are being made. Can you please explain why this change is
beneficial?

Thanks.

--
tejun
--
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/