Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp786369rwd; Wed, 31 May 2023 05:35:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ72sMyPQ5sU3nR1W9aeDqOkDtRu6zVSoScezcwocsGynyPNubiYWy0g7Cm4Mn+XjQZkW9p7 X-Received: by 2002:a17:902:ecc3:b0:1ac:5717:fd5 with SMTP id a3-20020a170902ecc300b001ac57170fd5mr6601259plh.60.1685536528863; Wed, 31 May 2023 05:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685536528; cv=none; d=google.com; s=arc-20160816; b=jtgkS0QXlb8D/Jo44jGM51XkTRnppXQ3CHnRaD5w8/YOHyCVGea09PHHfwmIaDud1M oWXR7vrCetX2+STwWD2dTi1dBH7lkvz4qyu4qWR5OKTdqEBLL5WdzlLWaRqGfK9Q95hL 7nWledsrJ4QnuPthU5HNqcHD2SFiFqcHuB0H8N5P1bxpwcUJHHVpJTL16YZrBYwrN3qu KD9rfazCwBy0ESdQGOVC6t93sFlH5qKlBnoP6vJsKOGJBIMdOpWY+WMMXc4MnTk6xcQP TyWfkm+7/w2OfjY43U5RtKPDD+PuMa+lKXkD6F7jIpjNveHeq91uCpnYJjirphbt21Wx veFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=IJ6RWmkaRZSpboMoH/r3gi9CMz8JDRmrwyEnXzDX0V4=; b=V5O673dNt/5wt/hqlXTcUi+bNmw6AnKSwZQwQ3ZZMPSGk4Htm1k3itcir6a5nX68sq Kqr1G2iVK3IOa298fG9LvKTX2n63KlnNxpL6G/ss6HIg8kuUl7lPq5t3EvT5XcaoJOXt JbLixMrVCF3ToHJ7UIxRhsWvyIGuDU89c2b8UM8yZuCXXfR89FTpbKhRwY1C/1ba5u/z NYV7eh/zBLkC9T2y3j6VibVol6yGIB3BeD7eZbx2RiGa92kNcH00A/TNEt8y/zXKagzz CzTMCPtvCQTocZNnziIGQ+FXluE+yMMMteyMVJ4ZwRSeFO0ObSuiuWOyyk+ic2ggFY8d Wi9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AHeTiweY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d5-20020a170902cec500b001ac78ac2c9csi804809plg.573.2023.05.31.05.35.14; Wed, 31 May 2023 05:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AHeTiweY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232298AbjEaMTs (ORCPT + 99 others); Wed, 31 May 2023 08:19:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229765AbjEaMTr (ORCPT ); Wed, 31 May 2023 08:19:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4EDC10F; Wed, 31 May 2023 05:19:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 69CD763889; Wed, 31 May 2023 12:19:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9880C433D2; Wed, 31 May 2023 12:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685535584; bh=MOaDbL+NiO4OhRTPz+e/kwwin5a8AKAbdpTTLVge0Yo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=AHeTiweYFXX2P52j7l6i6MADs9RfXctsbgXrUNXzzXe/FKKVpRY7rB1lIx5Vt/S26 ikZYC6v6fSKWlTpS/8cIdBqORXNwLP3Mqd2TDF7SOjX93x3qtDNvwCe8h/B8EZuAOO lBI7Ycu/DIcutr2uBZirHiStlzt1x+6LY/0qYt2IjdWQLPXh+dC8WIA8qVvpdjfJAs 4pzzBiYqRUcauM9SNwCykBOSC2YwtoxqPr6gTBens6KnVmEYoie6kcvlvIT/9y7ddd +QQgNTEfWR86l/OAvcdq+PRpf2n3OU/qvSfjv35Y8//vA/km+M2tTUMjFyAyRVfxAh 5U0QsHi7EqegA== Message-ID: <90e94292-4300-e7f0-1a37-72a5c3bd77dc@kernel.org> Date: Wed, 31 May 2023 14:19:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.2 Subject: Re: [PATCH] soc: qcom: pmic: Fix resource leaks in device_for_each_child_node() loops Content-Language: en-US To: =?UTF-8?B?6Lev57qi6aOe?= , "konradybcio@kernel.org" , "agross@kernel.org" , "andersson@kernel.org" , "neil.armstrong@linaro.org" , "linux-arm-msm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Cc: "opensource.kernel" References: From: Konrad Dybcio In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 31.05.2023 12:40, 路红飞 wrote: > > On 2023/5/31 17:03, Konrad Dybcio wrote:> >> On 31.05.2023 10:54, Lu Hongfei wrote: >>> The device_for_each_child_node loop in pmic_glink_altmode_probe should have >>> fwnode_handle_put() before return which could avoid resource leaks. >>> This patch could fix this bug. >>> >>> Fixes: 080b4e24852b ("soc: qcom: pmic_glink: Introduce altmode support") >>> >>> Signed-off-by: Lu Hongfei >>> --- >> This is the third revision of this patch, please version them accordingly. >> >> You can pass `-vN` to git format-patch and it'll do the job for you. >> >> Please also describe the changes since last revision below the --- line. >> >> Konrad > The latter two versions have added Fixes: tag, without any changes to the > > specific content of this patch. The commit message is an integral part of the patch, it's not only the diff that matters. Any change deserves a new revision number, unless you made a mistake when sending the emails (e.g. you didn't fill out the To: and Cc: fields properly), in which case you should use the [RESEND PATCH] tag. > > Just use the third version of this patch. Which I have to dig up by hand from the tens of patches I've received since, because you did not specify which one is the third version in the title. This also messes with patch workflow tools like b4. Konrad > > Thanks. > > Lu Hongfei > >>> drivers/soc/qcom/pmic_glink_altmode.c | 27 ++++++++++++++++++--------- >>> 1 file changed, 18 insertions(+), 9 deletions(-) >>> >>> diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c >>> index df48fbea4b68..a7fc6570fa1e >>> --- a/drivers/soc/qcom/pmic_glink_altmode.c >>> +++ b/drivers/soc/qcom/pmic_glink_altmode.c >>> @@ -395,7 +395,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, >>> ret = fwnode_property_read_u32(fwnode, "reg", &port); >>> if (ret < 0) { >>> dev_err(dev, "missing reg property of %pOFn\n", fwnode); >>> - return ret; >>> + goto err_node_put; >>> } >>> >>> if (port >= ARRAY_SIZE(altmode->ports)) { >>> @@ -405,7 +405,8 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, >>> >>> if (altmode->ports[port].altmode) { >>> dev_err(dev, "multiple connector definition for port %u\n", port); >>> - return -EINVAL; >>> + ret = -EINVAL; >>> + goto err_node_put; >>> } >>> >>> alt_port = &altmode->ports[port]; >>> @@ -420,33 +421,37 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, >>> >>> ret = devm_drm_bridge_add(dev, &alt_port->bridge); >>> if (ret) >>> - return ret; >>> + goto err_node_put; >>> >>> alt_port->dp_alt.svid = USB_TYPEC_DP_SID; >>> alt_port->dp_alt.mode = USB_TYPEC_DP_MODE; >>> alt_port->dp_alt.active = 1; >>> >>> alt_port->typec_mux = fwnode_typec_mux_get(fwnode); >>> - if (IS_ERR(alt_port->typec_mux)) >>> - return dev_err_probe(dev, PTR_ERR(alt_port->typec_mux), >>> + if (IS_ERR(alt_port->typec_mux)) { >>> + ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_mux), >>> "failed to acquire mode-switch for port: %d\n", >>> port); >>> + goto err_node_put; >>> + } >>> >>> ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_mux, >>> alt_port->typec_mux); >>> if (ret) >>> - return ret; >>> + goto err_node_put; >>> >>> alt_port->typec_switch = fwnode_typec_switch_get(fwnode); >>> - if (IS_ERR(alt_port->typec_switch)) >>> - return dev_err_probe(dev, PTR_ERR(alt_port->typec_switch), >>> + if (IS_ERR(alt_port->typec_switch)) { >>> + ret = dev_err_probe(dev, PTR_ERR(alt_port->typec_switch), >>> "failed to acquire orientation-switch for port: %d\n", >>> port); >>> + goto err_node_put; >>> + } >>> >>> ret = devm_add_action_or_reset(dev, pmic_glink_altmode_put_switch, >>> alt_port->typec_switch); >>> if (ret) >>> - return ret; >>> + goto err_node_put; >>> } >>> >>> altmode->client = devm_pmic_glink_register_client(dev, >>> @@ -455,6 +460,10 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, >>> pmic_glink_altmode_pdr_notify, >>> altmode); >>> return PTR_ERR_OR_ZERO(altmode->client); >>> + >>> +err_node_put: >>> + fwnode_handle_put(fwnode); >>> + return ret; >>> } >>> >>> static const struct auxiliary_device_id pmic_glink_altmode_id_table[] = {