Hi, - use kzalloc - no GFP_KERNEL in interrupt - kfree can take NULL
Signed-off-by: Oliver Neukum <[EMAIL PROTECTED]> Regards Oliver ---- --- linux-2.6/drivers/usb/serial/spcp8x5.c.alt 2008-02-12 14:53:25.000000000 +0100 +++ linux-2.6/drivers/usb/serial/spcp8x5.c 2008-02-12 15:42:54.000000000 +0100 @@ -199,8 +199,7 @@ static inline struct ringbuf *alloc_ring static inline void free_ringbuf(struct ringbuf *pb) { if (pb != NULL) { - if (pb->buf_buf != NULL) - kfree(pb->buf_buf); + kfree(pb->buf_buf); kfree(pb); } } @@ -334,17 +333,14 @@ static int spcp8x5_startup(struct usb_se dev_dbg(&serial->dev->dev, "device type = %d\n", (int)type); for (i = 0; i < serial->num_ports; ++i) { - priv = kmalloc(sizeof(struct spcp8x5_private), GFP_KERNEL); + priv = kzalloc(sizeof(struct spcp8x5_private), GFP_KERNEL); if (!priv) goto cleanup; - memset(priv, 0x00, sizeof(struct spcp8x5_private)); spin_lock_init(&priv->lock); priv->buf = alloc_ringbuf(SPCP8x5_BUF_SIZE); - if (priv->buf == NULL) { - kfree(priv); - goto cleanup; - } + if (priv->buf == NULL) + goto cleanup2; trace("(%d)priv = %p,priv->buf = %p\n", i, priv, priv->buf); @@ -357,6 +353,8 @@ static int spcp8x5_startup(struct usb_se trace("ok\n"); return 0; +cleanup2: + kfree(priv); cleanup: for (--i; i >= 0; --i) { priv = usb_get_serial_port_data(serial->port[i]); @@ -381,7 +379,6 @@ static void spcp8x5_shutdown(struct usb_ free_ringbuf(priv->buf); kfree(priv); usb_set_serial_port_data(serial->port[i] , NULL); - priv = NULL; } } trace("ok\n"); @@ -755,7 +752,7 @@ static void spcp8x5_read_bulk_callback(s trace("caught -EPROTO, resubmitting the urb\n"); urb->status = 0; urb->dev = port->serial->dev; - result = usb_submit_urb(urb , GFP_KERNEL); + result = usb_submit_urb(urb , GFP_ATOMIC); if (result) trace("faile submitting read urb %d\n", result); return; @@ -798,7 +795,7 @@ static void spcp8x5_read_bulk_callback(s /* Schedule the next read _if_ we are still open */ if (port->open_count) { urb->dev = port->serial->dev; - result = usb_submit_urb(urb , GFP_KERNEL); + result = usb_submit_urb(urb , GFP_ATOMIC); if (result) trace("faile submitting read urb %d\n", result); } @@ -839,7 +836,7 @@ static void spcp8x5_send(struct usb_seri port->write_urb->transfer_buffer_length = count; port->write_urb->dev = port->serial->dev; - result = usb_submit_urb(port->write_urb, GFP_KERNEL); + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) { trace("failed submitting write urb, error %d\n", result); priv->write_urb_in_use = 0; @@ -879,7 +876,7 @@ static void spcp8x5_write_bulk_callback( __FUNCTION__, urb->status); port->write_urb->transfer_buffer_length = 1; port->write_urb->dev = port->serial->dev; - result = usb_submit_urb(port->write_urb, GFP_KERNEL); + result = usb_submit_urb(port->write_urb, GFP_ATOMIC); if (result) trace("failed resubmitting write urb,%d\n", result); else - To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html