Hello. On 22-06-2012 19:42, Matthieu CASTET wrote:
If we don't read fast enough hidraw device, hidraw_report_event will cycle and we will leak list->buffer. Also list->buffer are not free on release. After this patch, kmemleak report nothing.
Signed-off-by: Matthieu CASTET<matthieu.castet@xxxxxxxxxx> --- drivers/hid/hidraw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index 36fa77b..89ba8bc 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c
[...]
@@ -317,6 +319,10 @@ static int hidraw_release(struct inode * inode, struct file * file) kfree(list->hidraw); } } + + for (i = 0; i< HIDRAW_BUFFER_SIZE; ++i) { + kfree(list->buffer[i].value); + }
{} not needed here, and according to CodingStyle shouldn't be here.
kfree(list); ret = 0; unlock: @@ -446,6 +452,10 @@ int hidraw_report_event(struct hid_device *hid, u8 *data, int len) int ret = 0; list_for_each_entry(list,&dev->list, node) { + int new_head = (list->head + 1) & (HIDRAW_BUFFER_SIZE - 1);
Empty line after declaration block wouldn't hurt...
+ if (new_head == list->tail) + continue; +
WBR, Sergei -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html