Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2841026rwb; Mon, 15 Aug 2022 12:23:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7B+6rgzX6PTNyGuVgwv3MBF9bjCJ87s8ZkdOETgq2+xL0ryMvPzstPG3B4ToK+4YA7M4m0 X-Received: by 2002:a17:907:1629:b0:730:7d10:639c with SMTP id hb41-20020a170907162900b007307d10639cmr10960916ejc.256.1660591387461; Mon, 15 Aug 2022 12:23:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660591387; cv=none; d=google.com; s=arc-20160816; b=f5bvz7O59gCQF18af6ymoC4QZg2f6WIhRf0LY/gcQ6Td9O5MRaPGaFPkAUuHinzUmI sMxck/4VNOLaoKQ2pNzCXHoQ4kbGb6FD7KItkPtAkHUgmGOnZilRIaokry+PpgncL564 t1pSArA0FD+oRXVCbCR8c1X5dDA/e3ca792EZI7bKzC1H90WMLrAfdz8z4/AQHJg9Nuc jc8noBDWUVl83CyXmiiopd1hP5mspuozAZb+ABegbxhoN+Qbs0yCJfLRtYdE0I86LiWV CHI/e8xM1/uPhHJ5LOLY+tlp1cMagdWZe2JrexmbXtrt0ZFIhx2FkM+TFt5PfAJQohw6 hLdg== 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=cztfBmA+i44koee+s9PpgSxRyyQ7hEm/9r7T3/cmy6Q=; b=xYTiLCJGWSs/VfpJ5uYOyhUQ9puyJNATs/OK+hhtWz6ofHZYbg8zvzs238G6MWkWXJ 63iXwMBYOF120YUdZBbOFypySMPnCqHP6P2iXFpfiOSF/RA8tQ1Ug5Ule3TcTS5ONGZ9 4ABDbTPK2kRj9jmtuO/2/jEtVf5Da+tNSgJXOMT2PpA07a3PyvjiUzbCt4FfFLHfuRmF vh71kh8Uqr0FxZZ4X4gbcN9seauu3ytNHVpXIlL1C+J8gu+aR3NpmRgIhT1gWhvhKoCN ZuarnDPMd4OLUeA+0q9mchpaJT+Xbrg8veT+0c6a7mRMapAD1AQweSWMNTZc/sZ/3qzj vzfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EKvcyYVN; 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 sa7-20020a1709076d0700b0073094ce02casi9254714ejc.791.2022.08.15.12.22.39; Mon, 15 Aug 2022 12:23:07 -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=@linuxfoundation.org header.s=korg header.b=EKvcyYVN; 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 S1343829AbiHOTUh (ORCPT + 99 others); Mon, 15 Aug 2022 15:20:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344802AbiHOTRa (ORCPT ); Mon, 15 Aug 2022 15:17:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BBE4550AD; Mon, 15 Aug 2022 11:38:52 -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 ams.source.kernel.org (Postfix) with ESMTPS id 924FCB8105C; Mon, 15 Aug 2022 18:38:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6258C433C1; Mon, 15 Aug 2022 18:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588729; bh=Ec5/oyhb00vaR4L1rErP9tSGFiWzLz6wckzSUZUh9pY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKvcyYVNqLnvbBNboXL6aPeEihDSKypkeC0gS8nHpjvsSW6F65BmjdCTSAKtt7Jn/ IIy6Ll8JdI9ynBwnHGGmO11FDUzc3OsxebOqn/IGRWH+onOGag/fcGpQL9cuvAfoDk LD6WeS71lzrUvRyfK1+K/HDFSNu9qVprHaFyrKRE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Max Filippov , Sasha Levin Subject: [PATCH 5.15 489/779] xtensa: iss: fix handling error cases in iss_net_configure() Date: Mon, 15 Aug 2022 20:02:13 +0200 Message-Id: <20220815180358.171051787@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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: Yang Yingliang [ Upstream commit 628ccfc8f5f79dd548319408fcc53949fe97b258 ] The 'pdev' and 'netdev' need to be released in error cases of iss_net_configure(). Change the return type of iss_net_configure() to void, because it's not used. Fixes: 7282bee78798 ("[PATCH] xtensa: Architecture support for Tensilica Xtensa Part 8") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Signed-off-by: Max Filippov Signed-off-by: Sasha Levin --- arch/xtensa/platforms/iss/network.c | 32 ++++++++++++++--------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/arch/xtensa/platforms/iss/network.c b/arch/xtensa/platforms/iss/network.c index 4801df4e73e1..08d70c868c13 100644 --- a/arch/xtensa/platforms/iss/network.c +++ b/arch/xtensa/platforms/iss/network.c @@ -511,16 +511,15 @@ static void iss_net_pdev_release(struct device *dev) free_netdev(lp->dev); } -static int iss_net_configure(int index, char *init) +static void iss_net_configure(int index, char *init) { struct net_device *dev; struct iss_net_private *lp; - int err; dev = alloc_etherdev(sizeof(*lp)); if (dev == NULL) { pr_err("eth_configure: failed to allocate device\n"); - return 1; + return; } /* Initialize private element. */ @@ -549,7 +548,7 @@ static int iss_net_configure(int index, char *init) if (!tuntap_probe(lp, index, init)) { pr_err("%s: invalid arguments. Skipping device!\n", dev->name); - goto errout; + goto err_free_netdev; } pr_info("Netdevice %d (%pM)\n", index, dev->dev_addr); @@ -557,7 +556,8 @@ static int iss_net_configure(int index, char *init) /* sysfs register */ if (!driver_registered) { - platform_driver_register(&iss_net_driver); + if (platform_driver_register(&iss_net_driver)) + goto err_free_netdev; driver_registered = 1; } @@ -568,7 +568,8 @@ static int iss_net_configure(int index, char *init) lp->pdev.id = index; lp->pdev.name = DRIVER_NAME; lp->pdev.dev.release = iss_net_pdev_release; - platform_device_register(&lp->pdev); + if (platform_device_register(&lp->pdev)) + goto err_free_netdev; SET_NETDEV_DEV(dev, &lp->pdev.dev); dev->netdev_ops = &iss_netdev_ops; @@ -577,23 +578,20 @@ static int iss_net_configure(int index, char *init) dev->irq = -1; rtnl_lock(); - err = register_netdevice(dev); - rtnl_unlock(); - - if (err) { + if (register_netdevice(dev)) { + rtnl_unlock(); pr_err("%s: error registering net device!\n", dev->name); - /* XXX: should we call ->remove() here? */ - free_netdev(dev); - return 1; + platform_device_unregister(&lp->pdev); + return; } + rtnl_unlock(); timer_setup(&lp->tl, iss_net_user_timer_expire, 0); - return 0; + return; -errout: - /* FIXME: unregister; free, etc.. */ - return -EIO; +err_free_netdev: + free_netdev(dev); } /* ------------------------------------------------------------------------- */ -- 2.35.1