Received: by 2002:ab2:687:0:b0:1f4:6588:b3a7 with SMTP id s7csp258966lqe; Wed, 10 Apr 2024 00:49:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVA9KTVOmN/KPNaKYIWPL1UrWHfrt2IFm1tXsnAwawosgAv+OPSt4fjbjDJiYsHVWFPp1d3RyF/tPoUuVm7gaBcQBQ6Z0RssqyFtWm02A== X-Google-Smtp-Source: AGHT+IHcsoUFFagQBcbKFyu27is1r/eJTjrlmvzTC9z2C46Ss25sD4R9h9RHqCAs2dTTpZarp2lG X-Received: by 2002:a17:907:7f87:b0:a51:d605:49ea with SMTP id qk7-20020a1709077f8700b00a51d60549eamr1610144ejc.8.1712735371225; Wed, 10 Apr 2024 00:49:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712735371; cv=pass; d=google.com; s=arc-20160816; b=yvVb4eTvep4E9iUgbSIkWc1GlJQ/V7sFObIZpPuO6BPDd8agWjUxomI7mJRS9Pw47N eto/5ZrZY/iCLKCFwJbX8RWiP/gjZxJasSvtN8QY/LTQrEDqHp4CPAmqAxj1rUTnF4fE /fQDrU8PtaQN982cpLaJ7JPJTl8jd/mHGyoKOMl91BzOIP4EouqccwoBhnuSPG5umyTy DLS4quiHHAgUvyVDj04+u+KE9kJejYjNg2legsP8IHHWSiWNXU2DoLl17U1wra4SPLS1 eugGzrHhYPe73Z3k9c8cU99J+oXtywlvSNZ7MP0WYUQ2eYClSxqW3w5i6bLWhMlfhHMm 98Gg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ae0D9UCfYFi2huQLmO6zAzFo6IEFdVglf2uczhGDJgQ=; fh=aZfR5YSFISY32Oi9C96GHuHzU6Vg3tZeBKoYnD+6/t0=; b=u6cpvm+5tncYUIPNrIxHDKyJWzIJaInCaBI6A+DOFx8ff8oNgLoc4lb3CMTDZBLSvZ /9Ku3K8lFPl+WPiFszJAPpCrQtlZpsL3mm6KTyd/uPCWLacY9UmcQHuo/J08tLXnOJ31 G4QzzkwhW+FyPLiLCPXUltsPdF046RZD+5n2L91piVNgB4Grm/KTPw3sWPMSzNfWsKqn TPdMUmpVuuvOrrMN6gqRtMkptiaRHjFZ4uAuOB42fF6G5RFNVDjU2Bo4p1/gdgX1ttC7 XMWNabW6OLHtBjAJczYM7d0pD1rFTC+7KhiJM0/GeP0NUUB/3MExf8JxsgGBecPMp8cr Xf6w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-138101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138101-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id qk13-20020a1709077f8d00b00a51a8bf3886si5794952ejc.23.2024.04.10.00.49.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 00:49:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-138101-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138101-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id E8C811F20EF4 for ; Wed, 10 Apr 2024 07:49:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8631413D500; Wed, 10 Apr 2024 07:49:11 +0000 (UTC) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CA0613CFB3 for ; Wed, 10 Apr 2024 07:49:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712735351; cv=none; b=SUraNKzXcTgfy1SRT8xeOprhEhYHoQS8y1t5jIqGDG8zSOOg9nL62YSvqzLMAJEkRBtrRjo1gw6tz4YzpmUXxeS/3ZBOyu+FbP6KyHLRzL12tXIfDfDCnTOO0Z9Xz5qXkG2f7L9qYaeZfYUatB48lKAL2vUDMi9JmBSPybhoVvo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712735351; c=relaxed/simple; bh=A5OJ5xcBefBzmfHqZgZLP9M0J2J7ENMi/66Dyfj/opI=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FY+Pjjs5hh+hGc4ugRnpLrV+MGtFejsC6zUACkGfZ5ul0lTBNjA59g2se6gCFduqML63x2WWEV6jCzn5ThJzDhCLBosvybGMvSNgV9QJEdeAzUlwXbDUfTEsRSGjBosgSHxE7bYotkrgXfVB4dBZmFUXOUDnB1fOZrUiZcWsxFQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VDvyp4kMszwRt4; Wed, 10 Apr 2024 15:46:10 +0800 (CST) Received: from kwepemm600013.china.huawei.com (unknown [7.193.23.68]) by mail.maildlp.com (Postfix) with ESMTPS id 01296180072; Wed, 10 Apr 2024 15:49:06 +0800 (CST) Received: from huawei.com (10.175.104.67) by kwepemm600013.china.huawei.com (7.193.23.68) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 10 Apr 2024 15:49:05 +0800 From: Zhihao Cheng To: , CC: , Subject: [PATCH 2/2] ubi: ubi_init: Fix missed ubiblock cleanup in error handling path Date: Wed, 10 Apr 2024 15:40:33 +0800 Message-ID: <20240410074033.2523399-3-chengzhihao1@huawei.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410074033.2523399-1-chengzhihao1@huawei.com> References: <20240410074033.2523399-1-chengzhihao1@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600013.china.huawei.com (7.193.23.68) The ubiblock_init called by ubi_init will register device number, but device number is not released in error handling path of ubi_init when ubi is loaded by inserting module (eg. attaching failure), which leads to subsequent ubi_init calls failed by running out of device number (dmesg shows that "__register_blkdev: failed to get major for ubiblock"). Fix it by invoking ubiblock_exit() in corresponding error handling path. Fixes: 927c145208b0 ("mtd: ubi: attach from device tree") Signed-off-by: Zhihao Cheng --- drivers/mtd/ubi/build.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 7f95fd7968a8..354517194099 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -1380,12 +1380,13 @@ static int __init ubi_init(void) if (ubi_is_module()) { err = ubi_init_attach(); if (err) - goto out_mtd_notifier; + goto out_block_exit; } return 0; -out_mtd_notifier: +out_block_exit: + ubiblock_exit(); unregister_mtd_user(&ubi_mtd_notifier); out_debugfs: ubi_debugfs_exit(); -- 2.39.2