Re: [GIT PATCH 2/3 (2nd draft)] Resend : Fix memory leak in qcserial driver

Sergei Shtylyov
2011-03-29T11:28:09Z

Hello.

On 29-03-2011 2:16, Steven Hardy wrote:

> Second draft of patch #2, this addresses the review comments made by Aristeu Rozanski, now usb_set_serial_data() is only called when we are not returning -ENODEV

Such comments should be put under --- tearline (which should appear under
your signoff). Otherwise Greg will have to hand edit them out of your patch.

> Original description:

Omit that please.

> Don't assign serial->private when doing the kzalloc or serial->private ends up pointing to freed memory in the event we return -ENODEV, instead call usb_set_serial_data(serial, data) at the end of the function, and only have one return-point.

Still not properly wrapped.

> Signed-off-by: Steve Hardy<shardy@redhat.com>

> diff --git a/drivers/usb/serial/qcserial.c b/drivers/usb/serial/qcserial.c
> index 6e3b933..b9b97ad 100644
> --- a/drivers/usb/serial/qcserial.c
> +++ b/drivers/usb/serial/qcserial.c
[...]
> @@ -199,9 +199,12 @@ static int qcprobe(struct usb_serial *serial, const struct usb_device_id *id)
> dev_err(&serial->dev->dev,
> "unknown number of interfaces: %d\n", nintf);
> kfree(data);
> - return -ENODEV;
> + retval = -ENODEV;
> }
>
> + /* Set serial->private if not returning -ENODEV */
> + if ( retval != -ENODEV )

No spaces after ( and before ) allowed.

WBR, Sergei