I have the same problem in my development.. Somewhere in my code:
unsigned char *data = urb->transfer_buffer ; .... if ( data == NULL ) dbg("%s - data is NULL !!!",__FUNCTION__ ); if ( urb->actual_length == 1 && data != NULL ) len = (int) data[0]; If I dont do this check in a usb callback function, I have kernel panic deference to null pointer ! But the fun stuff in this story is that I never see the debug " data is NULL !!! " so This never happen if I do this check.... Any idea ? Alain -----Message d'origine----- De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Satyam Sharma Envoyé : dimanche 29 juillet 2007 20:18 À : Oliver Neukum Cc : linux-usb-devel@lists.sourceforge.net; Petko Manolov; Greg Kroah-Hartman; Jesper Juhl; Linux Kernel Mailing List; [EMAIL PROTECTED] Objet : Re: [linux-usb-devel] [PATCH] USB Pegasus driver - avoid a potential NULL pointer dereference. On Sun, 29 Jul 2007, Oliver Neukum wrote: > Am Sonntag 29 Juli 2007 schrieb Jesper Juhl: > > On 29/07/07, Satyam Sharma <[EMAIL PROTECTED]> wrote: > > > Hi, > > > > > > On 7/29/07, Jesper Juhl <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > > > > > This patch makes sure we don't dereference a NULL pointer in > > > > drivers/net/usb/pegasus.c::write_bulk_callback() in the initial > > > > struct net_device *net = pegasus->net; assignment. > > > > The existing code checks if 'pegasus' is NULL and bails out if > > > > it is, so we better not touch that pointer until after that check. > > > > [...] > > > > > > Is it really possible that we're called into this function with > > > urb->context == NULL? If not, I'd suggest let's just get rid of > > > the check itself, instead. > > > > > I'm not sure. I am not very familiar with this code. I just figured > > that moving the assignment is potentially a little safer and it is > > certainly no worse than the current code, so that's a safe and > > potentially benneficial change. Removing the check may be safe but I'm > > not certain enough to make that call... > > pegasus == NULL there would be a kernel bug. Silently ignoring > it, like the code now wants to do is bad. As the oops has never been > reported, I figure turning it into an explicit debugging test is overkill, > so removal seems to be the best option. Ok, thanks. Updated patch below. [PATCH] pegasus: Remove bogus checks in urb->complete() callbacks urb->complete() callbacks registered in drivers/net/usb/pegasus.c needlessly check for urb->context != NULL, but that is not possible (the only way that can be possible would be a kernel bug elsewhere, and these checks would simply end up hiding that). So let's remove the bogus checks. Signed-off-by: Satyam Sharma <[EMAIL PROTECTED]> --- drivers/net/usb/pegasus.c | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-) diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index a05fd97..439ef9f 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c @@ -770,9 +770,6 @@ static void write_bulk_callback(struct urb *urb) pegasus_t *pegasus = urb->context; struct net_device *net = pegasus->net; - if (!pegasus) - return; - if (!netif_device_present(net) || !netif_running(net)) return; @@ -805,13 +802,9 @@ static void write_bulk_callback(struct urb *urb) static void intr_callback(struct urb *urb) { pegasus_t *pegasus = urb->context; - struct net_device *net; + struct net_device *net = pegasus->net; int status; - if (!pegasus) - return; - net = pegasus->net; - switch (urb->status) { case 0: break; ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel