Skip to contentSkip to conversation

media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data

PATCH Superseded Javier Martinez Canillas 2 participants 2 messages Jun 9, 2018 – Jun 14, 2018 Media (V4L/DVB)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data

The struct clk_init_data defined in isp_xclk_init() is a variable in the stack but it's not explicitly zero-initialized. Because of that, in some cases the data structure contains values that confuses the clk framework.

For example if the flags member has the CLK_IS_CRITICAL bit set, the clk framework will wrongly prepare the clock on registration. This leads to the isp_xclk_prepare() callback to be called which in turn calls to the omap3isp_get() function that increments the isp device reference counter.

Since this omap3isp_get() call is unexpected, this leads to an unbalanced omap3isp_get() call that prevents the requested IRQ to be later enabled, due the refcount not being 0 when the correct omap3isp_get() call happens.

Fixes 9b28ee3c9122 ("[media] omap3isp: Use the common clock framework")

---

 drivers/media/platform/omap3isp/isp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/omap3isp/isp.c +1 -1
index f22cf351e3e..ae0ef8b241a 100644
@@ -300,7 +300,7 @@ static struct clk *isp_xclk_src_get(struct of_phandle_args *clkspec, void *data)
 static int isp_xclk_init(struct isp_device *isp)
 {
 	struct device_node *np = isp->dev->of_node;
-	struct clk_init_data init;
+	struct clk_init_data init = { 0 };
 	unsigned int i;
 
 	for (i = 0; i < ARRAY_SIZE(isp->xclks); ++i)
Signature · 1 line
2.17.1
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Javier Martinez Canillas

The struct clk_init_data defined in isp_xclk_init() is a variable in the stack but it's not explicitly zero-initialized. Because of that, in some cases the data structure contains values that confuses the clk framework.

For example if the flags member has the CLK_IS_CRITICAL bit set, the clk framework will wrongly prepare the clock on registration. This leads to the isp_xclk_prepare() callback to be called which in turn calls to the omap3isp_get() function that increments the isp device reference counter.

Quoted 6 lines

Since this omap3isp_get() call is unexpected, this leads to an unbalanced omap3isp_get() call that prevents the requested IRQ to be later enabled, due the refcount not being 0 when the correct omap3isp_get() call happens.

Fixes 9b28ee3c9122 ("[media] omap3isp: Use the common clock framework")
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html