On Mon, 26 Aug 2013, Xenia Ragiadakou wrote:

> In usb_reset_and_verify_device(), hub_port_init() allocates a new bos
> descriptor to hold the value read by the device. The new bos descriptor
> has to be compared with the old one in order to figure out if device 's
> firmware has changed in which case the device has to be reenumerated.
> In the original code, none of the two descriptors was deallocated leading
> to memory leaks.
> 
> This patch compares the old bos descriptor with the new one to detect change
> in firmware and releases the newly allocated bos descriptor to prevent memory
> leak.
> 
> Signed-off-by: Xenia Ragiadakou <burzalod...@gmail.com>
> ---
> 
> Differences from version 2:
> 
> - fix identation
> - initialize udev->bos to null so that check fails if bos is uninitialized
> - move bos deallocation inside 'done' and 're_enumerate' paths to ensure
>   that the deallocation will be performed even if hub_port_init() fails
> - remove check (!udev->wusb && le16_to_cpu(udev->descriptor.bcdUSB) >= 0x0201)
>   since the checks that follow suffice

This looks good to me.  Martin, can you verify that it fixes your 
kmemleak issue?

Alan Stern

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

Reply via email to