Re: [PATCH] IPC: fix error case when idr-cache is empty in ipcget()

Andrew Morton
2007-10-15T20:13:53Z

On Thu, 11 Oct 2007 09:32:22 +0200
Pierre Peiffer <Pierre.Peiffer@bull.net> wrote:

> @@ -373,7 +376,7 @@ int ipcget_public(struct ipc_namespace *
> struct kern_ipc_perm *ipcp;
> int flg = params->flg;
> int err;
> -
> +retry:
> err = idr_pre_get(&ids->ipcs_idr, GFP_KERNEL);
>
> mutex_lock(&ids->mutex);
> @@ -406,6 +409,9 @@ int ipcget_public(struct ipc_namespace *
> }
> mutex_unlock(&ids->mutex);
>
> + if (err == -EAGAIN)
> + goto retry;
> +
> return err;
> }

Not pretty, is it? The idr interface isn't a good one. But then, any
storage library (aka container class) which allocates memory at insertion
time is a pain to handle in the kernel.

btw, idr_pre_get() should return 0 on success, else an errno - the current
interface is silly.