From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89DC9C433EF for ; Thu, 4 Nov 2021 06:04:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66941611C3 for ; Thu, 4 Nov 2021 06:04:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230301AbhKDGGj (ORCPT ); Thu, 4 Nov 2021 02:06:39 -0400 Received: from gandalf.ozlabs.org ([150.107.74.76]:35207 "EHLO gandalf.ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229912AbhKDGG2 (ORCPT ); Thu, 4 Nov 2021 02:06:28 -0400 Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4HlCkX4GkPz4xcG; Thu, 4 Nov 2021 17:03:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1636005829; bh=p/s4JP6PbvtWu7khsyF8vJ6QmABC6L59+cG94M8kDLc=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=EmbGkDhXHcKUm2lpYjR8DUXtGW9HMpO2NjVP3Q9G8oRoGvIfTQ6U1PfO0ey0OP0Xd ny5VwgSYcgfRia/ufrmRTdJDeeljrp4voPBfH5YNZV09/GCFoP/KLGmUHW/H/HX7pb v0YO1hbpvsqXajkmj4txxqkW9VKPyiUPR23rlm5U0qYNZfCKBs7yw4wG2u9aIH9xgF Hxmo3FzPOgF0Jc18QSXTbexj0F0RJRdhXimP92F+gpmjBS04H/mbUGu4QtsGbEbMqC 4CAd7PFmlLbyoUpYGFDVfB+pRROSgHCIcrrwyQk8RkND8E4q/l4On9EiHHjLyX3XyJ UDQrDE7+Ea4DA== From: Michael Ellerman To: Christophe JAILLET , 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: Re: [PATCH 2/2] soc: fsl: guts: Add a missing memory allocation failure check In-Reply-To: <4890990418ecbcfb8921efe8adb2019a03e5a1c1.1635969326.git.christophe.jaillet@wanadoo.fr> References: <1063e5a4738d897adcaffce2ab8e4e45f07998ff.1635969326.git.christophe.jaillet@wanadoo.fr> <4890990418ecbcfb8921efe8adb2019a03e5a1c1.1635969326.git.christophe.jaillet@wanadoo.fr> Date: Thu, 04 Nov 2021 17:03:47 +1100 Message-ID: <874k8s8njw.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christophe JAILLET writes: > 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. I think it's still correct to add: Fixes: a6fc3b698130 ("soc: fsl: add GUTS driver for QorIQ platforms") That is where the bug was introduced, and adding the tag creates a link between the fix and the bug, which is what we want. The fact that it also requires the revert in order to apply is kind of orthogonal, it means an automated backport of this commit will probably fail, but that's OK it just means someone might have to do it manually. There is some use of "Depends-on:" to flag a commit that is depended on, but you can't use that in a patch submission because you don't know the SHA of the parent commit. Possibly whoever applies this can add a Depends-on: pointing to patch 1. cheers > --- > 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