Re: [PATCH] fastboot: Introduce an asynchronous function call mechanism

From: Pekka Enberg
Date: Mon Oct 13 2008 - 03:15:20 EST


Hi Arjan,

On Mon, Oct 13, 2008 at 2:44 AM, Arjan van de Ven <arjan@xxxxxxxxxxxxx> wrote:
> +void call_async(int pool_number, int argc, ...)
> +{
> + struct async_item *item;
> + va_list ap;
> +
> + if (argc > 4 || argc < 0) {
> + WARN(1, KERN_ERR "Too many arguments to async function! Skipping...\n");
> + return;
> + }
> +
> + item = kmalloc(sizeof(struct async_item), GFP_ATOMIC);

Why is there no check for NULL here?

> + item->argument_count = argc;
> + va_start(ap, argc);
> + item->func = va_arg(ap, async_func_t_0);
> + if (argc > 0)
> + item->arg1 = va_arg(ap, void *);
> + if (argc > 1)
> + item->arg2 = va_arg(ap, void *);
> + if (argc > 2)
> + item->arg3 = va_arg(ap, void *);
> + if (argc > 4)
> + item->arg3 = va_arg(ap, void *);
> + va_end(ap);
> +
> + /* If we're not yet or no longer active, just process the work item in place */
> + if (!async_active) {
> + do_async_item(item);
> + kfree(item);
> + return;
> + }
> + spin_lock(&pool_lock);
> + pool_count[pool_number]++;
> + list_add_tail(&item->list, &list_pool[pool_number]);
> + wake_up(&waitqueue_pool[pool_number]);
> + spin_unlock(&pool_lock);
> +}
> +EXPORT_SYMBOL_GPL(call_async);
--
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/