Message ID | 20230805084114.1298-1-thunder.leizhen@huaweicloud.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp372659vqr; Sat, 5 Aug 2023 03:12:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfZIFT0WVhSNkcAgghV9p6cuJxjug0a+H74wxXesQ1UaDnam59xS1NX0AyxroKDdFhPJPR X-Received: by 2002:a17:907:7603:b0:99b:ff9d:93f2 with SMTP id jx3-20020a170907760300b0099bff9d93f2mr3276226ejc.42.1691230365088; Sat, 05 Aug 2023 03:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691230365; cv=none; d=google.com; s=arc-20160816; b=uFVX8uGs9DmczN1mP6x1urHjxmpdjQnZlq93Gq/K8Ldk4M7LFVXPtlFZ8eB2MwMgFk 9IbtqV4wtH+zuYaSWzdLqWUkw20aWr0gAN3xmPCwY737eoKKT5EnnanPrfZCaYJ5tjC3 1K8I82lvJocaEZ2g+IPCVP+OGNoUYSil4e7IG7kn2EOYxla95AqdVHAtYa70+NwAyP9g GnIg5uKArJuzrGuuxIBXUYCQxz+jldJfmTNr0zpKIMHkPWjI/+PrLU0bVcsY9mwy70+d S62HohwLWQLuON6fnPcsNxa6YUX91KPpGR8Ubq1gT4SJDLUr4EDBATUIqm0Y/CXd7u7W DfKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=YW2Zhoc9lypyHGfO47r8Jf+Q1jdeWHnd3Ckp5phG9k0=; fh=IVsjub5GkLM/axoPUNNIOqPI7DryKyw7On15pcrOviE=; b=Fdo+FFwp+b3o8I8moCy8FgqHtYZm9dgjk7GNL6vMh7BVAMoo44JYiYqImdRxUq0bc6 XsNV+Iak17Spv4Fx9P3NxwCIhz/3bEUUdcHrFWZCl3+gdUJ2WyY4Dv3aG+Jk+cp7yol0 zmhczeubzJmaH9pl64Kw6h6oivcz2t09bwfF+pS9IZSEVMCAfzTn30CoHLX6ESHqyul5 wa4JWDGf/EYZaHwo72WWKwexcMnIOf+W1R2vRVZRskW7+HodWyKVslzW3urPsbhMPB3X LEZxvjaWA+zCM//Iv/tJc5kMWNAknErsaOFrmj+sqLTRzKnDXp38dOp4vCSjcRW9Ozfe 9PvQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d26-20020aa7c1da000000b00522b8bc328asi2749967edp.305.2023.08.05.03.12.21; Sat, 05 Aug 2023 03:12:45 -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 S229573AbjHEIlz (ORCPT <rfc822;liqunnana@gmail.com> + 99 others); Sat, 5 Aug 2023 04:41:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229496AbjHEIlu (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 5 Aug 2023 04:41:50 -0400 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B734689 for <linux-kernel@vger.kernel.org>; Sat, 5 Aug 2023 01:41:48 -0700 (PDT) Received: from mail02.huawei.com (unknown [172.30.67.143]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4RHwzq4P0hz4f3pHw for <linux-kernel@vger.kernel.org>; Sat, 5 Aug 2023 16:41:43 +0800 (CST) Received: from huaweicloud.com (unknown [10.174.178.55]) by APP4 (Coremail) with SMTP id gCh0CgAHuKtGC85kcXBwPg--.1103S4; Sat, 05 Aug 2023 16:41:44 +0800 (CST) From: thunder.leizhen@huaweicloud.com To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J . Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org Cc: Zhen Lei <thunder.leizhen@huawei.com> Subject: [PATCH 0/2] kobject: Reasonably sanity check for kset->kobj.ktype Date: Sat, 5 Aug 2023 16:41:12 +0800 Message-Id: <20230805084114.1298-1-thunder.leizhen@huaweicloud.com> X-Mailer: git-send-email 2.37.3.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgAHuKtGC85kcXBwPg--.1103S4 X-Coremail-Antispam: 1UD129KBjvdXoW7Gr1rWr4rur4UKF1kXFyDAwb_yoWDuFb_GF y8AFyDJw47GFWfK3W2kws8Xry7Ca98ur15CF98tFZrJryfWr4DGr9xZFsIvr17uF45GFnr Ar1DKa9aywnF9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbzxYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_JFC_Wr1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwV A0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x02 67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40E x7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x 0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lw4CEc2x0rVAKj4xxMxAIw28IcxkI7VAKI48J MxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwV AFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv2 0xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4 v20xvaj40_WFyUJVCq3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E 14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7IU8j9aPUUUUU== X-CM-SenderInfo: hwkx0vthuozvpl2kv046kxt4xhlfz01xgou0bp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,KHOP_HELO_FCRDNS, SPF_HELO_NONE,SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773383571275915761 X-GMAIL-MSGID: 1773383571275915761 |
Series |
kobject: Reasonably sanity check for kset->kobj.ktype
|
|
Message
Leizhen (ThunderTown)
Aug. 5, 2023, 8:41 a.m. UTC
From: Zhen Lei <thunder.leizhen@huawei.com>
Currently, there are four API paths for adding or registering kobjects:
1. Call kobject_init() first then kobject_add()
2. kobject_init_and_add()
3. kset_register()
4. kset_create_and_add()
Except for kset_register(), the other three paths ensure that kobj.ktype cannot be NULL.
According to the description in Documentation/core-api/kobject.rst:
- A ktype is the type of object that embeds a kobject. Every structure
that embeds a kobject needs a corresponding ktype.
Add sanity check for kset->kobj.ktype in kset_register(), make sure that it cannot be NULL,
then all added or registered kobj/kset.obj, its ktype is not NULL. We can safely remove all
statements that check whether kobj.ktype is NULL. They're redundant.
Zhen Lei (2):
kobject: Add sanity check for kset->kobj.ktype in kset_register()
kobject: Remove redundant checks for whether ktype is NULL
lib/kobject.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)