From patchwork Sat Jun 9 12:22:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 50158 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com Received: from vger.kernel.org ([209.132.180.67]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fRctT-0008M6-86; Sat, 09 Jun 2018 12:22:55 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753216AbeFIMWw (ORCPT + 1 other); Sat, 9 Jun 2018 08:22:52 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:39660 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753101AbeFIMWv (ORCPT ); Sat, 9 Jun 2018 08:22:51 -0400 Received: by mail-wm0-f68.google.com with SMTP id p11-v6so8284679wmc.4 for ; Sat, 09 Jun 2018 05:22:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=8xsHvDyuu/3njWj5sUVONzEGDJDFAYdlf0VZaXeHr+U=; b=oF+brr5EgvwuVgEF3Sf/qK/RdSfw1EShZjkpQDd03Ok/GLNuEBMgsEQ1unVhduT1dM Eq3tukGgunDP7cBMWlHdRPEebitQUY7HAJBsfb8b2xZ3naThm/mCZ9GmeyExNNJm0z1p F16sCjWWmRMsEH8+6ktSKo2OvGEtyKP2SHCtiZVTkFmLQjkXa471xt19CSJNX6yYclXg RIoX3k3CONtPyo7LYizh+1AtaXEzrOTU8uU0Hkm+8a8ehOquL422FLjFsrekjaacBji/ LA45A68LP7UBr0sQOIUOkIdM3pOjwOYpqDw17bPJNP5ZzysDiBNHkBfvBvQpULVw+ZTA gnfw== X-Gm-Message-State: APt69E3rNbwxOG0b7oj9mMcKcaUDkNgtSXM4/ppk6dutaC//LAHWN1Er 6Vl41V5va4StpYcDtGxRtSQx0GjR+rc= X-Google-Smtp-Source: ADUXVKLU9PElsCCN8A1in8F5tYf7iV9Pkhz+A+DoraxAvEXQWjAzAfVYEC7ABWUPvvWQXyxhI/GNwQ== X-Received: by 2002:a1c:6803:: with SMTP id d3-v6mr4187683wmc.70.1528546970459; Sat, 09 Jun 2018 05:22:50 -0700 (PDT) Received: from minerva.home ([90.77.100.34]) by smtp.gmail.com with ESMTPSA id w15-v6sm38653373wro.52.2018.06.09.05.22.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 05:22:49 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Sakari Ailus , Javier Martinez Canillas , Mauro Carvalho Chehab , Laurent Pinchart , linux-media@vger.kernel.org Subject: [PATCH v2] media: omap3isp: zero-initialize the isp cam_xclk{a, b} initial data Date: Sat, 9 Jun 2018 14:22:45 +0200 Message-Id: <20180609122245.29636-1-javierm@redhat.com> X-Mailer: git-send-email 2.17.1 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The struct clk_init_data init variable is declared in the isp_xclk_init() function so is an automatic variable allocated in the stack. But it's not explicitly zero-initialized, so some init fields are left uninitialized. This causes the data structure to have undefined values that may confuse the common clock framework when the clock is registered. For example, the uninitialized .flags field could have the CLK_IS_CRITICAL bit set, causing the framework to wrongly prepare the clk on registration. This leads to the isp_xclk_prepare() callback being called, which in turn calls to the omap3isp_get() function that increments the isp dev refcount. 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") Signed-off-by: Javier Martinez Canillas Reviewed-by: Sebastian Reichel --- Changes in v2: - Correct some typos in the commit message. drivers/media/platform/omap3isp/isp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c index f22cf351e3e..ae0ef8b241a 100644 --- a/drivers/media/platform/omap3isp/isp.c +++ b/drivers/media/platform/omap3isp/isp.c @@ -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)