Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp216051imu; Thu, 10 Jan 2019 22:19:46 -0800 (PST) X-Google-Smtp-Source: ALg8bN4gqcpYpph98NV1qzP1COaXvd4cEdA6PF48tU4uzABGUhVHFtpgzZ/d2c0MsS1W+xPvBmJs X-Received: by 2002:a63:d604:: with SMTP id q4mr2099918pgg.175.1547187586419; Thu, 10 Jan 2019 22:19:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547187586; cv=none; d=google.com; s=arc-20160816; b=Matu7ccjKRnOSgFkRFmdlzgqfIyWJmiFl4WqXAOXQAkKCwZWpHlPkdfrJ9I7TwxHO+ eN8eHscLNItUYi/aVrwKwImrqxSTqS2CMSXYTLJEYLf6aKA3AxzqB0+sPAhc/wh9BgbK HZcpjQVdlr4Gn+0Q0gWHOvqPb3YTyZWgmGRRTyitfq3ZwqkAj7s0VtoGQJ0rAz8Rh/No g88buBIye+UaUCES3B3uMgylLadDnSNRnn9YLE+7U1IBYTExlapu0bnsMUds1P34BzIk ocDihYrwXT7IbndzofKrH589B8qT/hCe67UC60/+NScOjTlIfBroQy31Snx8b/8E5eMI 7SEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=FshGDDecfXh7reEU4Wr8KCr8PuerHOYXBawgk2BXosE=; b=Y6hNmP0V2LWGCSObGmvs0TYCz+qer4oICzF/vbVNVeNATa/NjQnzpu9IlqEv1JCEMb sqkPA/+TOq2+JL5ukskaiBFzReNS4drmDxIOFjfvH3RNKdMSs8vyVwiGUbYMzLh1QXjz OLkd5VMzb30oqv8RSx49VSE23wqYaR357Sw7If03vSSEfReqTbP63yxpmV+4admTz7d5 SHY11md+0yhGcjgCCGPcfnG5l3Dn4rlXA4+J7F2ebgCk5hS5eg+QB7hrvlqhdDsVbAPL zPFzk6xxu6gOtUeeTocKFnV+yoNjIuoG/IjRmuzjMjwfwktAraJxtPNVlIB4hJZgPMnZ JMiQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si74031654plr.189.2019.01.10.22.19.00; Thu, 10 Jan 2019 22:19:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729982AbfAKCnv (ORCPT + 99 others); Thu, 10 Jan 2019 21:43:51 -0500 Received: from 178.115.242.59.static.drei.at ([178.115.242.59]:49764 "EHLO mail.osadl.at" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727022AbfAKCnv (ORCPT ); Thu, 10 Jan 2019 21:43:51 -0500 Received: by mail.osadl.at (Postfix, from userid 1001) id AE90F5C033D; Fri, 11 Jan 2019 03:43:34 +0100 (CET) Date: Fri, 11 Jan 2019 03:43:34 +0100 From: Nicholas Mc Guire To: Li Yang Cc: Scott Wood , linuxppc-dev , lkml , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , Nicholas Mc Guire Subject: Re: [PATCH] soc: fsl: guts: us devm_kstrdup_const() for RO data Message-ID: <20190111024334.GA12140@osadl.at> References: <1544170963-8386-1-git-send-email-hofrat@osadl.org> <98aba52405a63829ee79c775c8b749f8431f5d2a.camel@buserror.net> <20181222075944.GA26155@osadl.at> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 10, 2019 at 01:43:01PM -0600, Li Yang wrote: > On Sat, Dec 22, 2018 at 2:02 AM Nicholas Mc Guire wrote: > > > > On Fri, Dec 21, 2018 at 08:29:56PM -0600, Scott Wood wrote: > > > On Fri, 2018-12-07 at 09:22 +0100, Nicholas Mc Guire wrote: > > > > devm_kstrdup() may return NULL if internal allocation failed, but > > > > as machine is from the device tree, and thus RO, devm_kstrdup_const() > > > > can be used here, which will only copy the reference. > > > > > > Is it really going to only copy the reference? That would require that > > > is_kernel_rodata(machine) be true, which it shouldn't be since it's not part > > > of the kernel image. > > > > > I had tried to figure out what is RO and what not but was not > > able to determine that - from the discussion it seemed that the > > assumption of RO is correct though I did not ask if it would > > satisfy is_kernel_rodata() so that explains the incorrect assertion. > > see https://lkml.org/lkml/2018/12/6/42 > > So then the only option is to check the return and cleanup > > on allocation failure as the orriginal patch proposed. > > Thanks for the good discussion. I will drop the previous patch. But > would it also be good to just have "soc_dev_attr.machine = machine" > directly? > I think that the intent is to switch to managed devm API so that the cleanup is handled properly currently you would get "machine" from of_property_read_string_index -> of_property_read_string_helper -> of_find_property which does not do any allocation - so there would actually not be anything to cleanup here - don?t see why your solution would not be suitable given the current API. the only advantage of the devm_kstrdup() is that underlying APIs internal changes would have no effect. thx! hofrat