From patchwork Tue Apr 25 16:06:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangtao Li X-Patchwork-Id: 13223448 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 lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 75EE9C77B73 for ; Tue, 25 Apr 2023 16:06:41 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1prLBf-0008RI-6I; Tue, 25 Apr 2023 16:06:38 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1prLBc-0008RA-8j for linux-f2fs-devel@lists.sourceforge.net; Tue, 25 Apr 2023 16:06:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=gXroYt61aQky65Pi8sxOVmca6w9Jd5lF8uIngz7u1Ek=; b=kN1Ijk7UwQ2+BKUc3CpCvm8nga Jn5IvsIQbaZAESJ6GW3w1bGf9jHg295Prb7qmrCwQtmT6r+ZnGWuB1/94i7JkUb6OjPcdtttRRYfT BAdaBjATUFVlZPMzzW1RFnw5cZyOXCHiWnIVCfiMHE/jrTWuqviJTsRCkWuEWlycJrso=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=gXroYt61aQky65Pi8sxOVmca6w9Jd5lF8uIngz7u1Ek=; b=N W9IymZZSyY0uy1pBwj1kdEYfiDvhgKWffHe0nIuwmyAyKN2OKd47v6/KUMwsybGqJURDK35viw4mq SIhBz7/ooPaFT3lIPOkZN2Qx1lIf/6bD+iSsgN4+oM5zKug7s8e4r1AdnPQS/OaZixdo4gzSA5vJ2 jH3c/CgzUiwVAUrs=; Received: from mail-sgaapc01on2118.outbound.protection.outlook.com ([40.107.215.118] helo=APC01-SG2-obe.outbound.protection.outlook.com) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1prLBY-001Jle-MM for linux-f2fs-devel@lists.sourceforge.net; Tue, 25 Apr 2023 16:06:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SIrsFHLezJU1yQ1Y/811YWijE7t8dkG3NdZNdHGCKsyPIX5z0jwqKZfzh2gGI6mn3qPRqdiButAWc0q/1/gMj4gcaC7s//hU6x55AKvj0UBJ8lL1lssVfV3P+dRL2SenOMSVQA08x62iOElSS8N8J84Ljxg0lJRKrQOHyirvlTS36NLd5Y/0gmBZXpuhgGxW4dvA1KlAg9NXehxxo9e5GIJtWIy8+EBCY6+b5GuFRI7fA60JUElR8xSegYCDSiWkSDlLiocE0V+7CJBXkCPXHzqPMnHT/dE5gnOKJUYbVYiPKuhx/4EpjaC51U40x8P+hvmyKHCYtDkjsBdFWrqsnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gXroYt61aQky65Pi8sxOVmca6w9Jd5lF8uIngz7u1Ek=; b=Uia83U8lLnMC+GqdgdCvoZRytOV8Ip6HClQYq20gSt88cegDA4bG48I60XzJ7DYeIacPzelWbi943lXFFk5MWwTXnJVdsMnzFX0kXk8vuL8PHKorffjDFss1D/KuLqiKxP4wUtHb3BZruKal4m3lHXm43fTPkSfBL7i8VhhFccYb0NN3FdMsYozTK9EUCr+XyMrUqcGVgo9iAtgLFfWvw7bxCmivXf40ijftYhRUybqXSaxy74u7gSJ9MDR+GYZhhvo837GQjDVxlHTsu6iff6NGpV3duoMWg4SNyzjm9auOGhiLdrB6/E8a4drOK4KAGXpJ+N6Gf2Ew6VzsZXURFA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gXroYt61aQky65Pi8sxOVmca6w9Jd5lF8uIngz7u1Ek=; b=Wn8rKdSDi6NdxopMXWO5vJKlPL3iAxC6tR4Tz11ysVeFUwGjXgi0pUKw+jg+Jz0xzbkmJGDGu8tbsF7bhKBlUWl18ygwQ/pQYtk80+UdB2htpfcouKgxNApgxlgk/LLwfF+JVmyDY3LI2W0axBhUsJbUDBntjMzmgRJvXIrVVPMRwzdkBmdHF6Z9qEIUipPa88SqaMqn3UCuySok9JgXtB4RODwKiYUDn0cU9JBmnqyg9uviivZS65n4J+lbyrQpi3+eL+EjATrgm9jhvrAUirenSJ+962tSO76NVvC1i9MoXblKBb7ZuCdHON5+qFqUDPpkPOC0wqDKIB589U2/ZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TYZPR06MB4078.apcprd06.prod.outlook.com (2603:1096:400:4::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 16:06:23 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::76d6:4828:7e80:2965%7]) with mapi id 15.20.6319.033; Tue, 25 Apr 2023 16:06:23 +0000 To: Jaegeuk Kim , Chao Yu Date: Wed, 26 Apr 2023 00:06:11 +0800 Message-Id: <20230425160611.79848-1-frank.li@vivo.com> X-Mailer: git-send-email 2.39.0 X-ClientProxiedBy: SI2PR06CA0007.apcprd06.prod.outlook.com (2603:1096:4:186::9) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB4078:EE_ X-MS-Office365-Filtering-Correlation-Id: a1a40f99-8fea-4629-4f9c-08db45a703ee X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fLWW+/FRF9Vh+daU16/nI9m4u/95k81Nt9OkrMW6pb3lv8xdWVqBOaHtfBl1yjX9ZPPPkddiDiWcYUi5vXX1RRCuzwMQ9gwJCwkWVR6A86FEj3rwzZIlUf6LSR66iMRxN3W/z1fwiC2n+0+HD1rLrcS4F9Lj+NhiEpkCcItNqfhyfCVr5zeS8rdXP/DhnIEyfSak1I0cA2vkUWVheg/agYIc48BZPpSNKgfZmqYIsEPAUZnj8DoZfmLAxTDknN3u4y+hezw2ZxaZ7RV1UAjJ5uxck9QHXYfCYGaLyXA9TMZlcADjVGWMMRgT3+1urL8dRK9jjh+JZBbzDjnPK+/WlgithLkjjFD/l9I1J/V79FytVH1LWcdV+iu+ou5aGkditzWQ3Nl4Fr2rZyuX+pYvAi/asvMES7jTjaw4TCUKayxn2IPvazbw9w8pTjR8///NEbHiN3/34q8uTw1GOT9AqKnp/ZPQ6fSe77BL/JolX0NxmTXpVqv+mdzjnpC3XUNUDAc+MGDz/Z64v05c3qY8oAKhZHKhBDBee5B2DBn0+krl89wtRWg6wmhqsX1uADSWnhyUNpS2vJc6U4/+YmTagmKULyMiRq/blwHFor+l1Zp7lSRZ8Zmm8n400W1HZI0I X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5269.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(39860400002)(136003)(396003)(366004)(346002)(451199021)(38350700002)(38100700002)(6506007)(6512007)(26005)(1076003)(186003)(2616005)(83380400001)(8936002)(2906002)(8676002)(5660300002)(36756003)(478600001)(6486002)(52116002)(110136005)(316002)(6666004)(4326008)(66556008)(41300700001)(66946007)(86362001)(66476007); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oBBaH1pM6PR2c6pRUI9lj8iWh+lXhKe1w8xR3sPlzkylGmRH3ArOE0ioFdHyrCIi/uHBb4rdxPiK4fZ1zlImITZTT0KYpnB+sEVuESH0IcjEu9CNw69aiGEO+bG77ggOT6tGqb1AQ6sT1PgGacWKgv6I+5C0Ip+bqK9M7Tf2LFseXkkVKmzqjIj6sv71hVYkda0udI4BTRrYcLxQimaex5ah9xcRgO2Ce9PCSnvWcmOrjWE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1fCksvENXVpwsgrvFL44a9CscmEI7iaajI8YkD4aAmOFGe4zhW4f2agv3sopwXyR3jkYg2626JvBhFeEmED046AcAo3rImFVZoI6PcvqK4vi2f8r05ai4q41RxJiHGIAEfCdpK3iLeEZhyOcLo4kWnXLleYfSA6RsP8NduQ8JEc99CsDeDk/b1DkSR7hsbjmn9Bgr8Z3ngnYXxjwoOEPHOvmI83j1XjUpmVhN3rlBjXZ8NRSE22mP872Pmu3Nee4PryrhY7qkMx0 X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1a40f99-8fea-4629-4f9c-08db45a703ee X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 16:06:23.2468 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9jWMQsOBQbF/jelfeG2TmtF9roo0hNGqo+2MbZxuNsyT2yeaD32ycJ2jvT4XmwzPauISC85ixfGGmzyOkFX71A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB4078 X-Headers-End: 1prLBY-001Jle-MM Subject: [f2fs-dev] [PATCH v2] f2fs: add sanity check for proc_mkdir X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Yangtao Li via Linux-f2fs-devel From: Yangtao Li Reply-To: Yangtao Li Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Return -ENOMEM when proc_mkdir failed. Signed-off-by: Yangtao Li Reviewed-by: Chao Yu --- v2: -removing check for proc in f2fs_unregister_sysfs and f2fs_register_sysfs fs/f2fs/sysfs.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 8ea05340bad9..467d743c801f 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -1386,12 +1386,19 @@ int __init f2fs_init_sysfs(void) ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype, NULL, "features"); - if (ret) { - kobject_put(&f2fs_feat); - kset_unregister(&f2fs_kset); - } else { - f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); + if (ret) + goto put_kobject; + + f2fs_proc_root = proc_mkdir("fs/f2fs", NULL); + if (!f2fs_proc_root) { + ret = -ENOMEM; + goto put_kobject; } + + return 0; +put_kobject: + kobject_put(&f2fs_feat); + kset_unregister(&f2fs_kset); return ret; } @@ -1430,23 +1437,24 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi) if (err) goto put_feature_list_kobj; - if (f2fs_proc_root) - sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root); + sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root); + if (!sbi->s_proc) { + err = -ENOMEM; + goto put_feature_list_kobj; + } - if (sbi->s_proc) { - proc_create_single_data("segment_info", 0444, sbi->s_proc, + proc_create_single_data("segment_info", 0444, sbi->s_proc, segment_info_seq_show, sb); - proc_create_single_data("segment_bits", 0444, sbi->s_proc, + proc_create_single_data("segment_bits", 0444, sbi->s_proc, segment_bits_seq_show, sb); #ifdef CONFIG_F2FS_IOSTAT - proc_create_single_data("iostat_info", 0444, sbi->s_proc, + proc_create_single_data("iostat_info", 0444, sbi->s_proc, iostat_info_seq_show, sb); #endif - proc_create_single_data("victim_bits", 0444, sbi->s_proc, + proc_create_single_data("victim_bits", 0444, sbi->s_proc, victim_bits_seq_show, sb); - proc_create_single_data("discard_plist_info", 0444, sbi->s_proc, + proc_create_single_data("discard_plist_info", 0444, sbi->s_proc, discard_plist_seq_show, sb); - } return 0; put_feature_list_kobj: kobject_put(&sbi->s_feature_list_kobj); @@ -1462,8 +1470,7 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi) void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi) { - if (sbi->s_proc) - remove_proc_subtree(sbi->sb->s_id, f2fs_proc_root); + remove_proc_subtree(sbi->sb->s_id, f2fs_proc_root); kobject_put(&sbi->s_stat_kobj); wait_for_completion(&sbi->s_stat_kobj_unregister);