Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5884743pxb; Mon, 14 Feb 2022 09:46:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwynNq1W/wkX/Tk1eOrq4r4oXU2TVTF2Kw4/DOU3Zn25ynWbGhn3/apwswD3rBYO1ZbBK6H X-Received: by 2002:a17:903:3093:: with SMTP id u19mr726311plc.105.1644860802629; Mon, 14 Feb 2022 09:46:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644860802; cv=none; d=google.com; s=arc-20160816; b=btuLD5p6B27LcEOJlV66Fcy5Dj6EK0BZUpjkphX0cRfBn3Vk8bFSq8mLdcfVVLFsHn 8Azxdv0FTnFNWu6/OLyIAYZlkyFYRqmzDx6Rbl0eoov2He/vzdywMDCJDOe2iPTQR6RX UBYdv3f05CV0rF2BgZsavkSHYt36Gd2ngt2farojRCeAa2nHVWHPMNwH+61n0gQpOXce f7DlsC/Ht6Vt1Vlw/p9eZwzSW8b/RSwFhc08TqqCjiByVk3W8vkOAcPkKyobga5ag+Vv of36CeLo04M0pgUcNqUz8eb8kQsz3XHHuKNPwhHBKUA/wuZ/yLG9Q4Fm1Lu3IkNtW0Ox oKCw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l6KZL4HztMdBZR51Tz7xYH3xp7i8TY+e5EQudCQj34E=; b=LaxijfS4WzQMn9prLqI4/z1wYrrk0EvYlkw/GSdfwUDLh24k7Tsxgqk9dNAb+GElhE eemDsE83jigWBtvsV2PUEfQSdbrPbt41uogD3eyBGNC13ejbTpXkYniTUGPNA/4QgNd+ Es3YvEIQE3lMn0wSS0m9bTv7zX7jWdBU6AfOjE5OnC/sZP4QeVOUGgafY1oNOBjT+MQ7 jLYqyvZvnmWhV0h+74YJ/aHi2jeFVkpUEqoWqrRYZKsG0+Xr8KemH86ceENrFWcA231z baajINH02AsoPjFbYrSY7OmP7L2zd4MdQLTh11zEh76AN6U9FRaFBN8bmY8r79J0/TX0 NgXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UF9sp0pZ; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q15si14419282plx.29.2022.02.14.09.46.25; Mon, 14 Feb 2022 09:46:42 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=UF9sp0pZ; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbiBNJz0 (ORCPT + 99 others); Mon, 14 Feb 2022 04:55:26 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344686AbiBNJvx (ORCPT ); Mon, 14 Feb 2022 04:51:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A57F6D381; Mon, 14 Feb 2022 01:43:08 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id D27BAB80D83; Mon, 14 Feb 2022 09:43:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8CD6C36AE2; Mon, 14 Feb 2022 09:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831785; bh=fEKu0wIsrTU9+RjmzFhznFG/l8LoKPcNOQsQGHl9h6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UF9sp0pZdx2rFPS4UcbAn7DIaXcXJl6LKI062+FcHuJYbuMuDpV+cEczCjN/XWXue OrWl+JgScXTMMvZqOcHVWFixBwt6DyI6JgZV/n3KZQIR1gDfIMFIxBFyTKc2PaQ7AX kdw/1JWvfNmP9FkCTGgUUupOhTwCQK/e9PYTFy8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heikki Krogerus , Sean Anderson Subject: [PATCH 5.10 095/116] usb: ulpi: Call of_node_put correctly Date: Mon, 14 Feb 2022 10:26:34 +0100 Message-Id: <20220214092502.051973305@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Sean Anderson commit 0a907ee9d95e3ac35eb023d71f29eae0aaa52d1b upstream. of_node_put should always be called on device nodes gotten from of_get_*. Additionally, it should only be called after there are no remaining users. To address the first issue, call of_node_put if later steps in ulpi_register fail. To address the latter, call put_device if device_register fails, which will call ulpi_dev_release if necessary. Fixes: ef6a7bcfb01c ("usb: ulpi: Support device discovery via DT") Cc: stable Reviewed-by: Heikki Krogerus Signed-off-by: Sean Anderson Link: https://lore.kernel.org/r/20220127190004.1446909-3-sean.anderson@seco.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/ulpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -250,12 +250,16 @@ static int ulpi_register(struct device * return ret; ret = ulpi_read_id(ulpi); - if (ret) + if (ret) { + of_node_put(ulpi->dev.of_node); return ret; + } ret = device_register(&ulpi->dev); - if (ret) + if (ret) { + put_device(&ulpi->dev); return ret; + } dev_dbg(&ulpi->dev, "registered ULPI PHY: vendor %04x, product %04x\n", ulpi->id.vendor, ulpi->id.product);