Re: [RFT][PATCH v1] media: zr364xx: Fix memory leak in ->probe()
From: Dan Carpenter <hidden>
Date: 2021-01-05 14:01:57
Also in:
linux-media
From: Dan Carpenter <hidden>
Date: 2021-01-05 14:01:57
Also in:
linux-media
On Wed, Dec 30, 2020 at 11:19:18PM +0200, Andy Shevchenko wrote:
When ->probe() fails in some cases it may not free resources. Replace few separated calls by v4l2_device_put() to clean up everything.
The clean up everything style of error handling is always buggy. For example, in this case, all the early error paths will now crash instead of leaking. The __videobuf_free() function will Oops when it dereferences "q->int_ops->magic". MAGIC_CHECK(q->int_ops->magic, MAGIC_QTYPE_OPS); The "q->int_ops" pointer is set in videobuf_queue_vmalloc_init(). There are probably other bugs as well. It's almost impossible to audit this style of error handling either for completeness or for crashyness. regards, dan carpenter