From patchwork Fri Dec 7 08:22:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Mc Guire X-Patchwork-Id: 10717617 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A08D9109C for ; Fri, 7 Dec 2018 08:27:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 901252E7D1 for ; Fri, 7 Dec 2018 08:27:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83BF62E7E1; Fri, 7 Dec 2018 08:27:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B347E2E7D1 for ; Fri, 7 Dec 2018 08:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=XhwWK83ThWwamPw9cbo43esCz/qeUpjrxG3kYITCPcw=; b=Kn0 xemzfsAmXBEG6/nVFFAUhlRndVyGmwWC+eAVudapRLeZvW9Q1v1ecG1dOqa+3Wufa2TCSv6QMsULl WZFjx0jGZ8184Rbik1ukLdEtnW7nqqGb+XpZp1zKmq5txPB4weBno06zhcxjFHzjqG0U62GEV8wFC uUVy5T2eHQDk+faRkD8ESppbuMbhmm4tngRnQsimQBxYcx9+fTom3PU/Z/SQ2BDlG+9dkzma9SH4y NknoBe8gn5TP2pjzr1wQ8/KBhmaXYYekr8oW4Ulb6jJu5n+lxrQYqWeU/jxppxkReFcb8PiLSuqnL e6thQtWCEs9zHJz2Uyg+ncgAv+kuOsg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVBTp-0007Os-IN; Fri, 07 Dec 2018 08:27:25 +0000 Received: from www.osadl.org ([62.245.132.105]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gVBTk-00076s-VT for linux-arm-kernel@lists.infradead.org; Fri, 07 Dec 2018 08:27:24 +0000 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id wB78PpRI010223; Fri, 7 Dec 2018 09:25:51 +0100 From: Nicholas Mc Guire To: Li Yang Subject: [PATCH] soc: fsl: guts: us devm_kstrdup_const() for RO data Date: Fri, 7 Dec 2018 09:22:43 +0100 Message-Id: <1544170963-8386-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181207_002721_643619_3F5C5A23 X-CRM114-Status: UNSURE ( 9.54 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Nicholas Mc Guire MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Nicholas Mc Guire Fixes: a6fc3b698130 ("soc: fsl: add GUTS driver for QorIQ platforms") --- Problem located by experimental coccinelle script Patch was compile tested with: multi_v7_defconfig (implies FSL_GUTS=y) Patch is against 4.20-rc5 (localversion-next is next-20181207) drivers/soc/fsl/guts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index 302e0c8..15071ec 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -157,7 +157,8 @@ static int fsl_guts_probe(struct platform_device *pdev) of_property_read_string_index(root, "compatible", 0, &machine); of_node_put(root); if (machine) - soc_dev_attr.machine = devm_kstrdup(dev, machine, GFP_KERNEL); + soc_dev_attr.machine = devm_kstrdup_const(dev, machine, + GFP_KERNEL); svr = fsl_guts_get_svr(); soc_die = fsl_soc_die_match(svr, fsl_soc_die);