Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1860310pxa; Mon, 3 Aug 2020 00:30:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/3LHWXTQbDwNqQmjD0Z0LGI9zWuaECY+NnXyhYdmK5REFFovHE5G+PT+iXRu5NJwBwFBE X-Received: by 2002:a17:907:20db:: with SMTP id qq27mr15983916ejb.550.1596439804458; Mon, 03 Aug 2020 00:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596439804; cv=none; d=google.com; s=arc-20160816; b=XAhpKmJ5eTtsrqBnn3O9KZaN2hnATb+dPr9Y+niScHYhnJ9HAqn8QRq3cbJWcJnu8T gZY/q8kF8qvJp+f6NeXOrsT0JysowulgIcybKDP9D0s2keVRKVO5+kjZWR/0vXQGukWL qKcAbJVLsJ5zGh3ilUS+G4qJbb3ziEMvAczbB7muDeHt/D/Y+x0k5lR7WZ9BROqq6aNQ uZaIICK/UeWnmVKVAjrmwdkzEqCot5v6Elx/4WhfRgqBfmhz8UuQJkg28JF9mka/bRSK 4nn+lNsabU2T3cWHlyBE5LrnxehBJiQ12H+/P1WegL5xcxFE9tUyGm/1z2Vy+c0+cPxn EP2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=N8zgir2t6iz+UzxYd4zks8afHq+WgZA6FxDNrIQU9Os=; b=wH/GJ7QbqfQn8uKCxAP4X8lackFSx74tMCJha8FCJtRqPidFphNop7BN+++NAs9EV2 m7al2lzV5hZOfCklpQN8muW6Z1ghBFftMKpn9ozLVPJcUbtlaHsmrTdnXJy8CenRPMZC hZIVV2LvuvsLKEW+UAYUtExCnltwdcV4bNFX5nS1FKtVZN+d/CysBERirbVbt/p+AiKJ SYDefijgIwmgZY6r+lw1M3HSRRy5uFNZa07bJE+kf/mCzVf6Bh4oOdcnewiBXPUYv+B4 BjINEPLM2nv75jqhKm3HlRRju+KWTivwBO/FgJg22b4/lu1iPJn8CO7AqIm7YpG+PIfc EX2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ayp/5J2Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 33si10551676edq.578.2020.08.03.00.29.42; Mon, 03 Aug 2020 00:30:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Ayp/5J2Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726150AbgHCH2G (ORCPT + 99 others); Mon, 3 Aug 2020 03:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725840AbgHCH2G (ORCPT ); Mon, 3 Aug 2020 03:28:06 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E838DC06174A; Mon, 3 Aug 2020 00:28:05 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id g33so1973190pgb.4; Mon, 03 Aug 2020 00:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=N8zgir2t6iz+UzxYd4zks8afHq+WgZA6FxDNrIQU9Os=; b=Ayp/5J2QerO98j5FTZXgOsm/l7P13p1jZTmxOiPYzilbU3iF4mOJ963AdohSAxIarp tUpf77dm/pgjeBVnKt6kOkQBcjo/qMHVf+ZHRblG6+4HGgns4nIWUNGdKApPCrZWQPNq 1MQYTS24sK9qMyflFSOtYPSjMKUMEoOFm33ZQE7B//nJLcZic9M15NCMfEUjWPLJ1K2v c1BCs8Sn1BhbeXWkDS6/160JlKVphA2DNOPnNPW41A+lkJ1/GXzMctWeNtxiXtbH7ML+ T/RgNadtDGFnFDLospGXMcXKtPxDjezWxM0PtOB2qNPlC5bwQF5b5Z/aNbEyq3c1tJSL V0Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=N8zgir2t6iz+UzxYd4zks8afHq+WgZA6FxDNrIQU9Os=; b=W67fiU9PROW+FjhyOt6Sh4skl/cp6TKYMTDj00xIBD+UpMIB/ui+9+zQO0DkcYfdrE 9v52csPf+OuDsmCZyM0DjkA4ljD9J0YJAYGHyYYwp6UUsj9eQAcVqMXoJl4C3ys0bGNL 02ZLHEAlfbE+z3i8iJxjZkizrDFCdjQctgcpGESHhsCBsZDHhAsB02NOBEYKW8KUs6Yj CjDpr+foDMVtoigvB4oSp2Uvit2Enoc7u80HTTXU0LYocysqszRw2F9UpulQ1nj+qXOw RyEitlaiyNCPR8ed/pZ4scnewUcfsdHfCTRxLQtMYAFX7Op0S5LmcF/+p89fjjkNAyKK 3ToA== X-Gm-Message-State: AOAM5320Q5QAstdG2cUay8ggmJzb+O+WTpcfl665mUpmXj5CG3qCueup tIl07qB8KdtVJdQVhizTFj1esLs+BA/FnhdFsqw= X-Received: by 2002:a62:7b4e:: with SMTP id w75mr14134631pfc.130.1596439685437; Mon, 03 Aug 2020 00:28:05 -0700 (PDT) MIME-Version: 1.0 References: <1908555.IiAGLGrh1Z@kreacher> In-Reply-To: From: Andy Shevchenko Date: Mon, 3 Aug 2020 10:27:50 +0300 Message-ID: Subject: Re: [PATCH] kobject: Avoid premature parent object freeing in kobject_cleanup() To: Qu Wenruo Cc: "Rafael J. Wysocki" , Greg Kroah-Hartman , Heikki Krogerus , Naresh Kamboju , Andy Shevchenko , LKML , Linux ACPI , "Rafael J. Wysocki" , Dmitry Torokhov , Guenter Roeck , "linux-btrfs@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 3, 2020 at 10:25 AM Andy Shevchenko wrote: > On Mon, Aug 3, 2020 at 9:47 AM Qu Wenruo wrote: > > On 2020/6/5 =E4=B8=8A=E5=8D=881:46, Rafael J. Wysocki wrote: > > > +void kobject_del(struct kobject *kobj) > > > +{ > > > + struct kobject *parent =3D kobj->parent; > > > + > > > + __kobject_del(kobj); > > > + kobject_put(parent); > > > > Could you please add an extra check on kobj before accessing kobj->pare= nt? > > I do not understand. Where do we access it? > kobject_put() is NULL-aware. Ah, I see, now. Should be something like struct kobject *parent =3D kobj ? kobj->parent : NULL; > > This patch in fact removes the ability to call kobject_del() on NULL > > pointer while not cause anything wrong. > > > > I know this is not a big deal, but such behavior change has already > > caused some problem for the incoming btrfs code. > > (Now I feels guilty just by looking into the old > > kobject_del()/kobject_put() and utilize that feature in btrfs) > > > > Since the old kobject_del() accepts NULL pointer intentionally, it woul= d > > be much better to keep such behavior. --=20 With Best Regards, Andy Shevchenko