From nobody Sun Apr 19 00:27:25 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB130C43334 for ; Fri, 8 Jul 2022 02:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236990AbiGHCCi (ORCPT ); Thu, 7 Jul 2022 22:02:38 -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 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" when device_register() fails, we should call ida_free(). Signed-off-by: Bo Liu Acked-by: Sergey Ryazanov --- 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 devic= e *parent) wwandev =3D kzalloc(sizeof(*wwandev), GFP_KERNEL); if (!wwandev) { wwandev =3D ERR_PTR(-ENOMEM); - ida_free(&wwan_dev_ids, id); - goto done_unlock; + goto error_free_ida; } =20 wwandev->dev.parent =3D parent; @@ -242,7 +241,7 @@ static struct wwan_device *wwan_create_dev(struct devic= e *parent) if (err) { put_device(&wwandev->dev); wwandev =3D ERR_PTR(err); - goto done_unlock; + goto error_free_ida; } =20 #ifdef CONFIG_WWAN_DEBUGFS @@ -251,6 +250,8 @@ static struct wwan_device *wwan_create_dev(struct devic= e *parent) wwan_debugfs_dir); #endif =20 +error_free_ida: + ida_free(&wwan_dev_ids, id); done_unlock: mutex_unlock(&wwan_register_lock); =20 @@ -448,8 +449,7 @@ struct wwan_port *wwan_create_port(struct device *paren= t, port =3D kzalloc(sizeof(*port), GFP_KERNEL); if (!port) { err =3D -ENOMEM; - ida_free(&minors, minor); - goto error_wwandev_remove; + goto error_free_ida; } =20 port->type =3D type; @@ -484,6 +484,8 @@ struct wwan_port *wwan_create_port(struct device *paren= t, =20 error_put_device: put_device(&port->dev); +error_free_ida: + ida_free(&minors, minor); error_wwandev_remove: wwan_remove_dev(wwandev); =20 --=20 2.27.0