From patchwork Fri May 5 18:39:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 90555 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp621069vqo; Fri, 5 May 2023 11:49:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6FYw0TJFAf/xM9xlrse2MAa0taZLXg/QAQjxGiqeMDW/YBguaLfSmi3qNpOjpDPlMg+rtF X-Received: by 2002:a17:90a:ca08:b0:24e:bb9:e4e6 with SMTP id x8-20020a17090aca0800b0024e0bb9e4e6mr2485141pjt.28.1683312549485; Fri, 05 May 2023 11:49:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683312549; cv=none; d=google.com; s=arc-20160816; b=LsyRo21FSNydTAZY9bgn+WOFZJaYqpmUb8RwyUJ5DDdZcbu+COPVzDtILIwDKvkckm n4QqQnn105Z8ylC3x5z7eU3ptd9lQmly9hjAX/0Zs/ybq9XwCo3aRdXrlYDLju4TUPFf JIFYlF6OFwat/6iDQ/gl7fz4uIeILAw3SKH0vUMA0JTAswg1ymUCi9bq48zE+HbWxzwh L6NEkuS0sTejUxrgrkuhJ5DHGvQV6GzzZSWvc6CgKEWmSJVOuchvy8zBNMpSv5MDyKAE 9ZXqDKI6dxlc7n7X+pp88vA+e5hGbYmKfzD5a7UUjuTJoOcEr0ChD8yytmDYA4Wd5kkV 5GmA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=mnw6geelSaRq346Pzls6ofHvmuoLhwJOFudxBY6bbI8=; b=JYAWfhRve5UfpI+TLR50XiKDS342QeWPpgficrYIlXjwozCYLsOvQ004RWKFjjn795 2qL0RDd4hFJGAVVIun4Hq/oxnT3P5jPpNJflxnUqJ7JzU2o66DsIl4zsTRmDNPxhrZ89 fTokzEWeapXSKAa9ynVTcIfkOQyiemktdwMVqZikro1rr90mAt+nRTfMohrRQE+/Vmei kHDJs5FSK5AtIFxH0K+kQcWrrEfTx4TC8vB2vz0b0eR03GFFbkmSOs5Y+7zUWvfQNyPK ER582TZ0lNrZHOYuFVQxYf6L8DnXGg8VEaq5tC97puiWKJUkZFzDNkNsYOi4nqHZrNkk w/Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=HNyqmFrT; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs125-20020a632883000000b0052c2904e37dsi2509572pgb.362.2023.05.05.11.48.56; Fri, 05 May 2023 11:49:09 -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=@wanadoo.fr header.s=t20230301 header.b=HNyqmFrT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233176AbjEESjz (ORCPT + 99 others); Fri, 5 May 2023 14:39:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231580AbjEESjn (ORCPT ); Fri, 5 May 2023 14:39:43 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 769331A4AD for ; Fri, 5 May 2023 11:39:41 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id v0L9pk2E0Gtqgv0L9pZwJH; Fri, 05 May 2023 20:39:39 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1683311979; bh=mnw6geelSaRq346Pzls6ofHvmuoLhwJOFudxBY6bbI8=; h=From:To:Cc:Subject:Date; b=HNyqmFrTormmtYO1mKS6qptrkzhC39BrHqC9jF3blBVbhK2TbhTTgNuCo94rx0J9K 6hBRWsiD/e+zisqWN/uxReWAtn5HDIS/M7SWxq85LhDBdwnDX6vVahdn179f9WAD9M j7pUd4x1S+Q4sxpvtlY/ubPb4OTkig2uv+jzXREk1pJJ+cgEFAiVJkb5e1zX4h3+iC ydc2TMMhmSvhdSFwgDsfuD+Htn1OwaE4iIPK0B8U2Al6bio7FHcn9V/6Cwu3ejoyRr e51zKNApddwBEw95Net0SVx8JMDxA/7IpZkUpM/lnnoPBAnk2yj6wsCET6lSrvcOQ+ Kngrr0jYJCexg== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Fri, 05 May 2023 20:39:39 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Tobias Waldekranz , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Florian Fainelli , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , netdev@vger.kernel.org Subject: [PATCH net] net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe() Date: Fri, 5 May 2023 20:39:33 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765081140071705384?= X-GMAIL-MSGID: =?utf-8?q?1765081140071705384?= Should of_mdiobus_register() fail, a previous usb_get_dev() call should be undone as in the .disconnect function. Fixes: 04e37d92fbed ("net: phy: add marvell usb to mdio controller") Signed-off-by: Christophe JAILLET Reviewed-by: Simon Horman Reviewed-by: Andrew Lunn --- drivers/net/mdio/mdio-mvusb.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/mdio/mdio-mvusb.c b/drivers/net/mdio/mdio-mvusb.c index 68fc55906e78..554837c21e73 100644 --- a/drivers/net/mdio/mdio-mvusb.c +++ b/drivers/net/mdio/mdio-mvusb.c @@ -67,6 +67,7 @@ static int mvusb_mdio_probe(struct usb_interface *interface, struct device *dev = &interface->dev; struct mvusb_mdio *mvusb; struct mii_bus *mdio; + int ret; mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb)); if (!mdio) @@ -87,7 +88,15 @@ static int mvusb_mdio_probe(struct usb_interface *interface, mdio->write = mvusb_mdio_write; usb_set_intfdata(interface, mvusb); - return of_mdiobus_register(mdio, dev->of_node); + ret = of_mdiobus_register(mdio, dev->of_node); + if (ret) + goto put_dev; + + return 0; + +put_dev: + usb_put_dev(mvusb->udev); + return ret; } static void mvusb_mdio_disconnect(struct usb_interface *interface)