Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754724AbdCBR1I (ORCPT ); Thu, 2 Mar 2017 12:27:08 -0500 Received: from mail-db5eur01on0078.outbound.protection.outlook.com ([104.47.2.78]:43008 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750841AbdCBR0O (ORCPT ); Thu, 2 Mar 2017 12:26:14 -0500 From: Leonard Crestez To: "sboyd@codeaurora.org" CC: "linux-kernel@vger.kernel.org" , "mturquette@baylibre.com" , "linux-clk@vger.kernel.org" Subject: Re: [PATCH] clk: core: Copy connection id Thread-Topic: [PATCH] clk: core: Copy connection id Thread-Index: AQHSi3wypNDeVI6X5k2xubw35qCiQKF4pqmAgADTDgCABKJMAIADcrKA Date: Thu, 2 Mar 2017 12:45:16 +0000 Message-ID: <1488458715.12287.18.camel@nxp.com> References: <60d115f6c11bc51cd8bc10c64cd222c3cdb43cc7.1487596492.git.leonard.crestez@nxp.com> <20170224204439.GD25384@codeaurora.org> <1488014402.6461.3.camel@nxp.com> <20170228080558.GL25384@codeaurora.org> In-Reply-To: <20170228080558.GL25384@codeaurora.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: codeaurora.org; dkim=none (message not signed) header.d=none;codeaurora.org; dmarc=none action=none header.from=nxp.com; x-originating-ip: [192.88.146.1] x-ms-office365-filtering-correlation-id: 78f4409e-f9d4-4298-b87e-08d46169fa32 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:AM5PR04MB3218; x-microsoft-exchange-diagnostics: 1;AM5PR04MB3218;7:8g6ElAo07xIZXXnxcy9+dDGUbm4E65R6GmSX5xKYg028cweJAnT7l4X5mKd5uHT3eoHLaoB219eWSf+RTKKNiogYM4CE0wSec5JgWSVsfetgDNhhO6eETRMYR9Nh2nxdXJi6CIoEYpcI2vgsrhWej59H/hW/f+apBSsX0Zd0U9LfYLFT3g89EuRje8Lz2dDqTk4V/7Akdt9KJjECNut8yzMwpYf35+CI4LMc9i4spBcZpiUZwvY9ffLGa58AZZSBEjDG52X+sot+Or6rK8Q4R0vy0SzZ52qysQoHFQH40E0K643XuVKfVMzw3BV81LHEwgH8UvNZMvUIh41pl+8A0w== x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(20161123558025)(6072148);SRVR:AM5PR04MB3218;BCL:0;PCL:0;RULEID:;SRVR:AM5PR04MB3218; x-forefront-prvs: 023495660C x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(39410400002)(39850400002)(39840400002)(39450400003)(39860400002)(377424004)(24454002)(3280700002)(122556002)(3660700001)(6512007)(2906002)(92566002)(2950100002)(54906002)(7736002)(103116003)(6506006)(2351001)(2900100001)(2501003)(99286003)(305945005)(53936002)(66066001)(6436002)(36756003)(229853002)(6486002)(25786008)(77096006)(106116001)(76176999)(5660300001)(54356999)(110136004)(1730700003)(8676002)(38730400002)(33646002)(8936002)(5640700003)(6916009)(81166006)(6246003)(102836003)(4326008)(50986999)(189998001)(93886004)(3846002)(6116002)(86362001);DIR:OUT;SFP:1101;SCL:1;SRVR:AM5PR04MB3218;H:AM5PR04MB3219.eurprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <49BA70200CC3744A9540D7BF4E7B5C03@eurprd04.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Mar 2017 12:45:16.2702 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR04MB3218 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v22HS8UO017785 Content-Length: 1891 Lines: 41 On Tue, 2017-02-28 at 00:05 -0800, sboyd@codeaurora.org wrote: > On 02/25, Leonard Crestez wrote: > > > > On Fri, 2017-02-24 at 12:44 -0800, Stephen Boyd wrote: > > > > > > On 02/20, Leonard Crestez wrote: > > > > > > > > Some drivers use sprintf to build clk connection id names but > > > > the > > > > clk > > > > core will save those strings and occasionally print them back. > > > > Duplicate > > > > the con_id strings instead of fixing all the users. > > > Good catch. What about dev_id though? That could also have the > > > same problem if some device is removed and we're still holding a > > > reference to the kobject's name. This is probably more rare than > > > what is happening here, but still seems possible that we might > > > trip over that later. > > A device should normally free the clks it uses before it is > > destroyed. > > This means that if dev_id is pointing to freed memory then the clk > > itself was probably leaked, right? > Sure. clk_get_sys() could be called and then we could have > something sprintf the dev_id there. A quick grep doesn't show any > place where that happens though so it seems safe right now. > > That said, it would be nice to clearly document that we don't > expect dev_id to be freed or changed during the lifetime of the > clk structure, but we do allow con_id to change. Perhaps the copy > shows that, but a comment would also be useful so we don't have > people wondering why dev_id isn't copied as well. This should be mentioned on the public documentation for clk_get_sys, clk_get and devm_clk_get, right? These seem to be the public entry points to the clk subsystem and users are expected to read their docs. Do you want me to resend the patch with these notes? I'm not comfortable adding to documentation when I don't fully understand the system myself. I only discovered this while looking into unrelated driver issues.