Re: [PATCH] USB: Driver for CH341 USB-serial adaptor
Oliver Neukum <[email protected]>
| Newsgroups | gmane.linux.usb.devel |
|---|---|
| Message-ID | <[email protected]> |
Am Dienstag 21 August 2007 schrieb Frank Kingswood:
Hi,
> +int ch341_get_status(struct usb_device *dev)
> +{
> + char *buffer;
> + int r = -ENOMEM;
> + const unsigned size = 8;
> +
> + dbg("ch341_get_status()");
> +
> + buffer = kmalloc(size, GFP_KERNEL);
> + if (!buffer)
> + goto out;
> +
> + r = ch341_control_in(dev, 0x95, 0x0706, 0, buffer, size);
> + /* return value ignored */
Why is it ignored?
> + r = 0;
> +
> +out: kfree(buffer);
kfree() will take NULL, but that's not a reason to call it if you know
you have a NULL pointer.
> +/* allocate private data */
> +static int ch341_attach(struct usb_serial *serial)
> +{
> + struct ch341_private *priv;
> + int r;
> +
> + dbg("ch341_attach()");
> +
> + /* private data */
> + priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL);
> + if (!priv)
> + return -ENOMEM;
> +
> + priv->baud_rate = DEFAULT_BAUD_RATE;
> + priv->dtr = 1;
> + priv->rts = 1;
> +
> + r = ch341_configure(serial->dev, priv);
> + if (r < 0)
> + return r;
Memory leak in the error case.
Regards
Oliver
-------------------------------------------------------------------------
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/
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel