From patchwork Wed Apr 12 03:11:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 82235 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp33035vqo; Tue, 11 Apr 2023 20:16:16 -0700 (PDT) X-Google-Smtp-Source: AKy350YMxkRYmE/Cw9fXL7F0/b/2eboY3kgPGZhUDNazsX41ojyKgZM6BIWrNtxcoFRCC79xa2XR X-Received: by 2002:a17:902:e892:b0:1a5:16fb:628b with SMTP id w18-20020a170902e89200b001a516fb628bmr21178244plg.24.1681269376556; Tue, 11 Apr 2023 20:16:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1681269376; cv=pass; d=google.com; s=arc-20160816; b=O2usmprU73xpIgghwuTCn/lSxgQ9pqbnH3CxvQSJLtSTbUpxuaqZ7p0SM49JiHv1E+ +Kkm4HtFRYDyj4sRzf3x5ZF89kw+QK+nhS7O1LgTcp25Q+6K1I5Pk5ABiyGos1RVZfni 3nAf1fbrwsN2FUAKYfpM0nJ/By220nRKmtEXKyv6lDn3EZOry+0wCXmQDoCyF6V8I5T3 YwAHVKEjFGUwJhvhYLuwVsCmwelyIUKHd5K2o37C7QaRJkQ/H4L7UaRSgN+mJIou75j2 bw6b2Qxq9JicNkjpCduk5sKarMud0fvfimXiX5VIKtSZxzsNB9h7xi1FedNxmI/2Jt0O BTnQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=9zXQNDGCKEzOQKyI2e5H8HfU3Z0SsSS5A3HLrl5PEqI=; b=hfAJQOkC1xbJB7wh6yu69pIkR0TSngfyBQeo8fc3eRtUdcVLT0wiqVzmpwcqXubNHV P0GN4e8Zbf4d1nRAGrgXvPTa1ozv5IPDbMq/gHKotkFmTfVY2Dx5NkMnZYIzkyBit/3y H6/1sxadcGdMG353acLYfVMVsNJ6X5KsSH4EjFXF2a6d8u0A0aF5wvKHUKi8RWUdG8h9 cGrBZMB5RtezdNMVcZM8xWiVrtGoge0PAGGWeaWxrN4mjwKYjBFIrTIM4VRiDWtR94eV 761jhaemstZs/zzOPki0MnQoOd/sVgYSl3XU0SoHdmsDhYjBYACfgrHjzh/x2CPxWMF6 6C1Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=RIVv4CSb; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t12-20020a170902b20c00b001a1abc91980si14613333plr.211.2023.04.11.20.16.04; Tue, 11 Apr 2023 20:16:16 -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=@vivo.com header.s=selector2 header.b=RIVv4CSb; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229490AbjDLDLa (ORCPT + 99 others); Tue, 11 Apr 2023 23:11:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229452AbjDLDL2 (ORCPT ); Tue, 11 Apr 2023 23:11:28 -0400 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2105.outbound.protection.outlook.com [40.107.215.105]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 570B3119 for ; Tue, 11 Apr 2023 20:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SifmJLq8GBM80T8ktPEVziTfPRJdPzZAg9wEI3gUM2gjX+vFc74j/9b9sY4xr/ViOSV8Wy7zlGbxBjJXTG+EA4JcDXw+4zgIy+Z307+YqaBv5LO+yGd0G8ajsQYhMBBsQq6HW/we0SqsY9Qry8E8WXaytIi+2rswSYYEaD6cqJ65Slt5BsNE3CPynjb0WJcOJHqDmNsuVYGjaewPaOG6UqFwmmBE64Q3mZsbGys/8i7PdmlF4LpZ0z8Uk/nEO2AJPMy8tWQEvzwpPZhzI1Pr2UFBF4+TGOoLvtuayEj0rQ4mnI47jArMjwOMd1eO4OXV0F7rUx8IlFjNI1JWVmrDRA== 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=9zXQNDGCKEzOQKyI2e5H8HfU3Z0SsSS5A3HLrl5PEqI=; b=T+3UiqMPdhuiPw07knRL9oZwwSLaQcWph40D4zgybvQkzzpsvVuvjwuyVsHnzw+LYHYzX8KnUTbW+ntBAkv2uJqccRQoRDqFA24G+9EAdjl3Xx1MA8ZmB51v7HZjYqsCYGxc/dokp2aHtkOZ7nDhvcSHcYL+KQWu9pODHLQQXUTLERVLHq9xbatzdtkHs6uoxPeWNCDBS6NifQR4SRw/1RmQV7xKfwY/noac5hb82dcjouBTI9POa+boQtQ36EKRhp8k2c8cYjvFP5MFARPfcTVqed0oQjI44sKsEhVhkgCP5DjEHWfB7h7ypltoxhxNeUtcGhfq6MuOd8Yl9+byyg== 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=9zXQNDGCKEzOQKyI2e5H8HfU3Z0SsSS5A3HLrl5PEqI=; b=RIVv4CSbVcL9tgc3jPFoIZdOma8NPLeI7OnTg0jtUlCZ/VZ8/2Kxe7J1gjgthkJNtp2ItPHowSDpT4JCDLEB9+0LHmEaTNx09dr9/D4Sf8Dw4gjRqLbwVLdF+7rU5P0JgcElRhYvaPVOGqn3N1SJvy1D67YH1G6E9+w1pf6pTJGkULs2AY3vzR8/NpyQVSrEqJXFoZwBzUR/RP64F1HcfMPP4k++r3/hTQ+dMDxaIMiqgh6fK/yIKm0wX93L8tEKq3kavRIrs6FQ9dJTcsgjFGh9stUyupLNLTLqNARDXmIcMIz6JsnOB6HrqmCf0DpEEVnzj0PdY5K+Yuawek/ncA== 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 TY0PR06MB5777.apcprd06.prod.outlook.com (2603:1096:400:270::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Wed, 12 Apr 2023 03:11:22 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::a3a1:af8e:be1e:437c%6]) with mapi id 15.20.6277.038; Wed, 12 Apr 2023 03:11:22 +0000 From: Yangtao Li To: Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu Cc: Yangtao Li , linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] erofs: don't access kobject object members directly Date: Wed, 12 Apr 2023 11:11:10 +0800 Message-Id: <20230412031110.8965-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:4:194::16) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5777:EE_ X-MS-Office365-Filtering-Correlation-Id: 1818bfa1-0230-4598-2a0d-08db3b03976a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m7zt65m4LE2jhkWdvJTeJTaHaKsIWc3/rCKYTIiAbRIk1tVjljH24nObg5QS47pGqVW6KW5l1cPnFCD7s3hrlu6C5AfxQ9fBUJpPzTDG7xMS0+nY/MIV7WGLc4SpuB0onR/Z1Jk35cF4ir+7o7fBR72GG8dDZ2yY+DXiFMC1jw4XklGr8hRNyPcFK0lDuk3W008yYkDZB9heZRDARhTaDQ8/5Axqd7WijNOssdshw+tkb/hR2wfLJw3J3FMrjpRdlxgEJGqEHmrKpcF3Xfc8Bec86d7d8WT6yplx3jCE1KNyfLTXa2LDOXOYWSKZVhJIkyqhlOannSiAa0PLkZVPyliy8GLtD/JBkRMM9+kzioMJYXSokUelXya2jnw2Q1Q6S1V/Kk9wk0ioXDhfdDAmBxj+XGYLtrYazA37djVIZKz565Wgd9vK3mkDEOQcIeUi53v7XUGS5MtKLmDmQ0UFXYGFmRUQlm9YSxFqNEVc3bG0SZTq9g5Nqjr6ukBYCH3v9tb3agjOkS1SXc2M1LbWFMkAd0Vu0+O5QCa0WwFePIzkO+3qHAZWgKGvSCS1RBEX42DnDw19yxmPQF83K3td0f1eSraenlP53V1ACHYmldXWwzsYIOXaOscpJT7108dr 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)(396003)(346002)(136003)(366004)(376002)(39860400002)(451199021)(478600001)(110136005)(5660300002)(8936002)(8676002)(66556008)(66476007)(4326008)(66946007)(41300700001)(316002)(2906002)(36756003)(38350700002)(38100700002)(83380400001)(2616005)(52116002)(6486002)(6512007)(26005)(1076003)(6506007)(186003)(86362001)(6666004);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2ZAPPFD+1BB1pg1jNYMQIExoXw+qoAaq1hQS+SzNNPm6vDXecFymBTJXgmdo8j0ePDAb2G2ifhkL+8qocpeYH4ecUobU/JYMz9MX8FZMNhKYHUjS/0t1NxoHSYvRmLu3goOX6n3tVs9pI4yarvYVzo/T6E3Vb/1JgDtgDwMFWmrMpo97szKDWrSsQJ22BM75MSen0JQpCYr1pjKkVRy+Ctzx1JjOrISoLj6bwhBrMGFKwd3ulruXx5gOj1QP9IgyDSw+cx2WWeMMyUCYGyusv3FB+DTp+B/0X/FU2tzvd+UJI6P9Ju5/AZgvFaP7zbJ1nRUUnBFYjQ03IEemWTpQWJC8mP9K7o2MRxfJLnxTsqLhhZke6VooJDeJXSMC913jxOpTL5njT3JLWo+EvM1A3a0RBDeZb4rf5xnWuKMcnj/ugD9CrbBwvUNaTFITZhZXyXd9LxGQt8aw3sverf72/2ITDrhzOyK30jdkFoelpTeIenuyQmYlfDntD5ECiisLHg/MQGMJEVFwIb8yPT0Z5/KidRs/YEMP+MtNnq3YIdKIHYmQcFOqSI5vExhn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fa1-0230-4598-2a0d-08db3b03976a X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 03:11:21.6637 (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: xDYqbIOGsFsPhtZY5tqOE7AVrX5F0LxSZFBlZgsrMkrsODFAvGX+8pIbkn3fgO+pedinxNUWeQ+de6IrurFSZg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5777 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762938717813599969?= X-GMAIL-MSGID: =?utf-8?q?1762938717813599969?= It is better not to directly access the internal members of the kobject object, especially kobject_init_and_add() may failure. BTW remove unnecessary kobject_del(), kobject_put() actually covers kobject removal automatically, which is single stage removal. Signed-off-by: Yangtao Li --- fs/erofs/internal.h | 1 + fs/erofs/sysfs.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h index f675050af2bb..f364b1e9b35b 100644 --- a/fs/erofs/internal.h +++ b/fs/erofs/internal.h @@ -177,6 +177,7 @@ struct erofs_sb_info { /* sysfs support */ struct kobject s_kobj; /* /sys/fs/erofs/ */ struct completion s_kobj_unregister; + bool sysfs_registered; /* fscache support */ struct fscache_volume *volume; diff --git a/fs/erofs/sysfs.c b/fs/erofs/sysfs.c index 435e515c0792..c38018d3c442 100644 --- a/fs/erofs/sysfs.c +++ b/fs/erofs/sysfs.c @@ -228,6 +228,7 @@ int erofs_register_sysfs(struct super_block *sb) kfree(str); if (err) goto put_sb_kobj; + sbi->sysfs_registered = true; return 0; put_sb_kobj: @@ -240,8 +241,7 @@ void erofs_unregister_sysfs(struct super_block *sb) { struct erofs_sb_info *sbi = EROFS_SB(sb); - if (sbi->s_kobj.state_in_sysfs) { - kobject_del(&sbi->s_kobj); + if (sbi->sysfs_registered) { kobject_put(&sbi->s_kobj); wait_for_completion(&sbi->s_kobj_unregister); }