Re: [PATCH] ci13xxx_udc.c: _gadget_stop_activity fix possible NULL pointer use

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

 



Hi,

On Mon, Apr 23, 2012 at 04:07:37PM +0200, Michael Grzeschik wrote:
> Call container_of after we have ensured that gadget is not NULL.
> 
> Signed-off-by: Michael Grzeschik <m.grzeschik@xxxxxxxxxxxxxx>
> ---
>  drivers/usb/gadget/ci13xxx_udc.c |    5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/gadget/ci13xxx_udc.c b/drivers/usb/gadget/ci13xxx_udc.c
> index 9283ab0..7b03cf5 100644
> --- a/drivers/usb/gadget/ci13xxx_udc.c
> +++ b/drivers/usb/gadget/ci13xxx_udc.c
> @@ -1629,7 +1629,8 @@ __acquires(mEp->lock)
>  static int _gadget_stop_activity(struct usb_gadget *gadget)
>  {
>  	struct usb_ep *ep;
> -	struct ci13xxx    *udc = container_of(gadget, struct ci13xxx, gadget);
> +	struct ci13xxx *udc;
> +
>  	unsigned long flags;
>  
>  	trace("%p", gadget);
> @@ -1637,6 +1638,8 @@ static int _gadget_stop_activity(struct usb_gadget *gadget)
>  	if (gadget == NULL)
>  		return -EINVAL;
>  
> +	udc = container_of(gadget, struct ci13xxx, gadget);

There's no way for gadget to be NULL when we call
_gadget_stop_activity(), what you need is to drop the unnecessary gadget
== NULL check. If it happens to be NULL, it actually deserves to oops as
it would mean something is really, really broken (either the compiler or
the HW).

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux