From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755781AbcITRbK (ORCPT ); Tue, 20 Sep 2016 13:31:10 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:47848 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755226AbcITRbH (ORCPT ); Tue, 20 Sep 2016 13:31:07 -0400 DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 7BA2A6151E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=sboyd@codeaurora.org Date: Tue, 20 Sep 2016 10:31:05 -0700 From: Stephen Boyd To: Julia Lawall Cc: mturquette@baylibre.com, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: question about clk_hw_register_fixed_factor Message-ID: <20160920173105.GA8319@codeaurora.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/20, Julia Lawall wrote: > Hello, > > The function clk_hw_register_fixed_factor from > drivers/clk/clk-fixed-factor.c contains: > > struct clk_init_data init; > ... > fix->hw.init = &init; > ... > hw = &fix->hw; > ... > return hw; > > It looks like hw would then contain a dangling pointer, to init. Should > this be nulled out, or does it not matter because it is certain that no > one will look at it anyway? Or did I miss a null assignment elsewhere? > Yes this is a common pattern in clk drivers. The init structure is not used after clk_register() (or its variants) is called, so there will typically be a dangling pointer in clk_hw to the clk_init_data structure. Sometimes that structure is allocated on the stack, which leads to other problems like people forgetting to initialize all the members. Usually they forgot to set flags to something and then clk framework does very odd things. We could null out the init pointer if we really cared, but so far this hasn't been a problem. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project