Re: [PATCH] musb: Add workqueue for URB giveback

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Am Freitag, 26. Februar 2010 11:39:06 schrieb Ajay Kumar Gupta:
> +struct queue *create(void)
> +{
> +       struct queue *new;
> +       new = kmalloc(sizeof(struct queue), GFP_ATOMIC);
> +       if (!new)
> +               return NULL;
> +       new->next = NULL;
> +       return new;
> +}
> +void push_queue(struct musb *musb, struct urb *urb)
> +{
> +       struct queue *new, *temp;
> +
> +       new = create();
> +       new->urb = urb;

And you happily follow the NULL pointer in the error case.

> +
> +       temp = musb->qhead;
> +
> +       spin_lock(&musb->qlock);
> +       while (temp->next != NULL)
> +               temp = temp->next;
> +       temp->next = new;
> +       spin_unlock(&musb->qlock);
> +}

A design allocating memory in giveback is problematic. At least you need
to handle a failure to allocate memory. But you'd better handle this by putting
the list into the private part of the URB.

	Regards
		Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux