Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4412374imw; Thu, 7 Jul 2022 19:04:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vUm8kkbHwgEXexci1myyuBLjogNoKBIbJlGNUHveHHbekdB2YUGp0BhL7B86ldz0MewF2v X-Received: by 2002:a17:907:7627:b0:72a:9098:e4d3 with SMTP id jy7-20020a170907762700b0072a9098e4d3mr1103460ejc.389.1657245876790; Thu, 07 Jul 2022 19:04:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657245876; cv=none; d=google.com; s=arc-20160816; b=cDlCfI/3c0Fq6JeHda9GQQTaHv6+nqNtgnvlMUTxkprFbVSlAhXF8E/WS1RJ82aOGI rYL1A5J58LAQrv0arglH6WOPTQ1eg4ZlOmTboHBHyczzmVZ4uV5F8kaRMdAdDhUq8/E+ prnhvnTYtvn6AKj8aNwtQUV/KQGAU7UUAklgVsp/5PidRNyUb4gVvbcFcnYKrAenYpgG 2xhoSdD2UHRKjIkZr8xbGsyE6Z50sOI+T3itTMPC75rnFMtUAREkOVMccQTQ53ki98lv UD0LpTSjg8HzzL3CrWvUNQuPLbGuKHYYOwSwLq+xHcF+/QHJOWFXNC6mj+YVmR5s6Ze4 Hefw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:mime-version:message-id :date:subject:cc:to:from; bh=PPZDogOAdDXznxcjUj0GTWX/tI+AU0x1Ej/dlrTew7o=; b=nKE1JGciR91ow1upIE4HiJzGljL3via3oyBzC0mdval0jSH8APkxd38hP8IOTZMixV 25josC6W85Np0JnJ2YSDI6xtK/WhLzWEvvr3hUAewBAwT3hzJAGaohpcZq2ff8ZRBQFw y856KhisuBCYdGBTe+DzQNX6qyRo6gtc3bIHw9SN6c9VoGoESWX+P1Pe53T85nCqIJSq scyCFWpb7euls+3G2/vOXJEBZGILJd4IWU+qm5ivJzC0QMYBgJT+Dk1l/DY+lzcz1OSF 9nfdt7e+E2sITa6+6DOQOxb0Fy6jED8PFMiamQadYmN5i4w2SUlFeRaTJEwzHqzTOyMd sRmg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jw7-20020a17090776a700b006fea42b2e6fsi34487743ejc.642.2022.07.07.19.04.10; Thu, 07 Jul 2022 19:04:36 -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; 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 S236802AbiGHCCg (ORCPT + 99 others); Thu, 7 Jul 2022 22:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236922AbiGHCCc (ORCPT ); Thu, 7 Jul 2022 22:02:32 -0400 Received: from unicom145.biz-email.net (unicom145.biz-email.net [210.51.26.145]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5073F73908; Thu, 7 Jul 2022 19:02:30 -0700 (PDT) Received: from ([60.208.111.195]) by unicom145.biz-email.net ((D)) with ASMTP (SSL) id CZK00025; Fri, 08 Jul 2022 10:02:25 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201612.home.langchao.com (10.100.2.12) with Microsoft SMTP Server id 15.1.2507.9; Fri, 8 Jul 2022 10:02:25 +0800 From: Bo Liu To: , , , , , , CC: , , Bo Liu Subject: [PATCH] net: wwan: call ida_free when device_register fails Date: Thu, 7 Jul 2022 22:02:23 -0400 Message-ID: <20220708020223.4234-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.200.104.97] tUid: 2022708100226f1151e7cf1643e555c40cf86075d3ed9 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, 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 when device_register() fails, we should call ida_free(). Signed-off-by: Bo Liu --- drivers/net/wwan/wwan_core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c index b8c7843730ed..0f653e320b2b 100644 --- a/drivers/net/wwan/wwan_core.c +++ b/drivers/net/wwan/wwan_core.c @@ -228,8 +228,7 @@ static struct wwan_device *wwan_create_dev(struct device *parent) wwandev = kzalloc(sizeof(*wwandev), GFP_KERNEL); if (!wwandev) { wwandev = ERR_PTR(-ENOMEM); - ida_free(&wwan_dev_ids, id); - goto done_unlock; + goto error_free_ida; } wwandev->dev.parent = parent; @@ -242,7 +241,7 @@ static struct wwan_device *wwan_create_dev(struct device *parent) if (err) { put_device(&wwandev->dev); wwandev = ERR_PTR(err); - goto done_unlock; + goto error_free_ida; } #ifdef CONFIG_WWAN_DEBUGFS @@ -251,6 +250,8 @@ static struct wwan_device *wwan_create_dev(struct device *parent) wwan_debugfs_dir); #endif +error_free_ida: + ida_free(&wwan_dev_ids, id); done_unlock: mutex_unlock(&wwan_register_lock); @@ -448,8 +449,7 @@ struct wwan_port *wwan_create_port(struct device *parent, port = kzalloc(sizeof(*port), GFP_KERNEL); if (!port) { err = -ENOMEM; - ida_free(&minors, minor); - goto error_wwandev_remove; + goto error_free_ida; } port->type = type; @@ -484,6 +484,8 @@ struct wwan_port *wwan_create_port(struct device *parent, error_put_device: put_device(&port->dev); +error_free_ida: + ida_free(&minors, minor); error_wwandev_remove: wwan_remove_dev(wwandev); -- 2.27.0