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

From: Andrew Morton
Date: Mon Oct 15 2007 - 16:13:55 EST


On Thu, 11 Oct 2007 09:32:22 +0200
Pierre Peiffer <Pierre.Peiffer@xxxxxxxx> 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.

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