Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp829830pxb; Wed, 3 Nov 2021 13:07:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFvuoWI/MY7KYRlGLUZN1/CAMgqMzacwFLC02EGjZgG/5pl5Zn31Bj3UQuG1RplglHd1Ih X-Received: by 2002:a17:906:e103:: with SMTP id gj3mr5141187ejb.456.1635970065451; Wed, 03 Nov 2021 13:07:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635970065; cv=none; d=google.com; s=arc-20160816; b=Eswc3MsEzAia4gd1MRnDx2a0dDl1zwsIG4BaJrKRpjitJo3qtawppfJ0xWNe5REqaH fKHLQteI9bCb7yrsSEP8aiiJlibbqZseFmCnOp1ONejQog1tEXfvT67rc6Hu4EZ7AObA F5xcuFS3i/9i2oexN1biDVtwI3SR6RVo+yYwZKAXdjsqRHp65hHstTqPkzeDdKnSq5Eq O38gI8k/YJXin5kXcmrAR0J1mWNfWCeOpH8Im5oBccP2rKUMSPD4fmkVCjewTQaw97p6 b0PH5w1E+FhKL/oxfJS3lT99wO480BcRyzbpbfsuGTzlVHdTsB6fJkAwRCJTHikutiKn QGuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kOP472y7TbGeFrmkQMS6VNzDGPmZW6oxm9P2EPrCwcM=; b=tUCgqJxEOrPWrTMixyNIKkqPRRLkQ2heVDAQqPGt1i67cqSzCNfCwCNrcViDFwI4hu Lc27s/Dv3aHcbU8tve+LUxWm2jUyYVaRaPKbIuZc9r2hrz7pkTCoLswOURR30TiZyXr0 zqXnUtBdVilDO7ve6axN3HqTBsR/EVXyEqZH0xO9XSYg5evWP3WGwiVW656oH0yw10LM KPbWBIOPbcCc3jQauNmj6pkMNyjEWvIh2uIpAesFqV3tu0jrDyjjw79RU59ib5p+4ojh yTYE/NjHoTQTAm9v/Mp8NhX0NJigNOhEU2a58Wt1GKc5coaasDn6HYgns2BnF3MKy+Uw H82g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d8si6547070edm.486.2021.11.03.13.07.19; Wed, 03 Nov 2021 13:07:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231381AbhKCUDN (ORCPT + 99 others); Wed, 3 Nov 2021 16:03:13 -0400 Received: from smtp03.smtpout.orange.fr ([80.12.242.125]:50997 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231325AbhKCUDN (ORCPT ); Wed, 3 Nov 2021 16:03:13 -0400 Received: from pop-os.home ([86.243.171.122]) by smtp.orange.fr with ESMTPA id iMR0mtlAhUGqliMR1msAVW; Wed, 03 Nov 2021 21:00:35 +0100 X-ME-Helo: pop-os.home X-ME-Auth: YWZlNiIxYWMyZDliZWIzOTcwYTEyYzlhMmU3ZiQ1M2U2MzfzZDfyZTMxZTBkMTYyNDBjNDJlZmQ3ZQ== X-ME-Date: Wed, 03 Nov 2021 21:00:35 +0100 X-ME-IP: 86.243.171.122 From: Christophe JAILLET To: leoyang.li@nxp.com, tyreld@linux.ibm.com Cc: linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH 2/2] soc: fsl: guts: Add a missing memory allocation failure check Date: Wed, 3 Nov 2021 21:00:33 +0100 Message-Id: <4890990418ecbcfb8921efe8adb2019a03e5a1c1.1635969326.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.30.2 In-Reply-To: <1063e5a4738d897adcaffce2ab8e4e45f07998ff.1635969326.git.christophe.jaillet@wanadoo.fr> References: <1063e5a4738d897adcaffce2ab8e4e45f07998ff.1635969326.git.christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If 'devm_kstrdup()' fails, we should return -ENOMEM. While at it, move the 'of_node_put()' call in the error handling path and after the 'machine' has been copied. Better safe than sorry. Suggested-by: Tyrel Datwyler Signed-off-by: Christophe JAILLET --- Not sure of which Fixes tag to add. Should be a6fc3b698130, but since another commit needs to be reverted for this patch to make sense, I'm unsure of what to do. :( So, none is given. --- drivers/soc/fsl/guts.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c index af7741eafc57..5ed2fc1c53a0 100644 --- a/drivers/soc/fsl/guts.c +++ b/drivers/soc/fsl/guts.c @@ -158,9 +158,14 @@ static int fsl_guts_probe(struct platform_device *pdev) root = of_find_node_by_path("/"); if (of_property_read_string(root, "model", &machine)) of_property_read_string_index(root, "compatible", 0, &machine); - of_node_put(root); - if (machine) + if (machine) { soc_dev_attr.machine = devm_kstrdup(dev, machine, GFP_KERNEL); + if (!soc_dev_attr.machine) { + of_node_put(root); + return -ENOMEM; + } + } + of_node_put(root); svr = fsl_guts_get_svr(); soc_die = fsl_soc_die_match(svr, fsl_soc_die); -- 2.30.2