Re: [Linux-uvc-devel] [PATCH] uvc: kmalloc failure ignored in uvc_ctrl_add_ctrl()

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

 



On Thursday 24 September 2009 10:50:39 Paulo Assis wrote:
> Laurent,
> 
> > That's not enough to prevent a kernel crash. The driver can try to
> > dereference ctrl->data if ctrl->info isn't NULL. You should only set
> > ctrl->info if allocationg succeeds. Something like
> >
> >        ctrl->data = kmalloc(ctrl->info->size * UVC_CTRL_NDATA,
> > GFP_KERNEL); if (ctrl->data == NULL)
> >                return -ENOMEM;
> >
> >        ctrl->info = info;
> 
> Without reading any code this doesn't seem correct, how can you use
> ctrl->info->size if you haven't set ctrl->info yet?
> 
> Did you mean something like this:
> 
>  ctrl->data = kmalloc(info->size * UVC_CTRL_NDATA, GFP_KERNEL);
>  if (ctrl->data == NULL)
>          return -ENOMEM;
> 
>  ctrl->info = info;
> 
> 
> Like I said I haven't read the code but this looks better.

Oops, you're right. My bad. Thanks for catching this.

-- 
Regards,

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

[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux