Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1858834pxa; Mon, 3 Aug 2020 00:26:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy40kRqNxKSztHQn1934AQH+LYL5FGP6BlXCyiZRODfiFHrY59tZzM9yYqHvNgTM9/xWPVo X-Received: by 2002:a50:d8c2:: with SMTP id y2mr14399114edj.114.1596439561110; Mon, 03 Aug 2020 00:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596439561; cv=none; d=google.com; s=arc-20160816; b=uGE+X5RVnIJKR7VHoFe3VWQqKNo+n37cT91XlhCJkQDm5Tmyz3t75Y0JhoWpvHyvMF 8jzXBnOQHMyCgPxlZVf7zQ4sor1EJKIdLugmQUIALNq9tUaFX3NlF0AXqpSe3zO4nUVO 8wC9++7ySc8+lglUlJA1ydMGKbUXO1L0UsEHoJo5UkA37pocjPbLqHNoKe7uS3pRvN4b UNAqk3stHvsQPmxPAwImiyZstCamAXYke/h73P3KDxyqgVvDE9Zw+3OftBLhx9bPk7AR RAN1h5lFZsbN0OBbqdB/hS3+7bkVdq3unwJtld4UDZhaXf+M44j1tpZ+yzJ94jUOgnut OOsQ== 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=to4odp1EU84jY7NPS+Ne28o7/CevkLRl0Wqah8jQXE8=; b=Tp5KWibgaVWr9sA5/1oYyWw8p5Js5wjVjHtvR52B9Hw/3V9Sfcmvpzz6TKziW0UVnO GRewA/A2YWOcwWY5CKSbpadwsCxzIfIqAhv5U5wmv40pqmPtgRUf7sdNSJMMng/wDo8D SSvgMOVCRKBzJzMM8jdf2Pe5rf0m+7PnVM9toDFCz/i1v1reKYMVpIxixHa1fpStwlv1 PUXmtW27Pf1crMOyFzsfNJrKnfIQhTbLRNRA9jSBDPhz7HxOzPcm6TmQ5zfE0y6dTMeG eFS34cUvoPZSv6Ou8G39vsFxRn/Txsn2NZQpELinCPwoL2PEV0QV0Lh8cMo6+6ON1BGm CTOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=O5SDH4Wd; 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 l22si10028684ejg.450.2020.08.03.00.25.39; Mon, 03 Aug 2020 00:26:01 -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=O5SDH4Wd; 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 S1726058AbgHCHZ3 (ORCPT + 99 others); Mon, 3 Aug 2020 03:25:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725270AbgHCHZ0 (ORCPT ); Mon, 3 Aug 2020 03:25:26 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BF9FBC06174A; Mon, 3 Aug 2020 00:25:26 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id i92so7272033pje.0; Mon, 03 Aug 2020 00:25:26 -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=to4odp1EU84jY7NPS+Ne28o7/CevkLRl0Wqah8jQXE8=; b=O5SDH4WdNlUsy4HbeFubvtlZJpGBS5lHiqd28mVxNJcoQvt95IPUdwOMzy9qeB/kBL J7LSKwEMD7+MFD5DQ+nxSPf3hmOFD5giyledMdrvjGQtJ9S5gDnchD/AQ9OUB6oC5xMe HHCj6htwsVAEdxlPw02DH5S5uGqV9zdBidwYEW9RV/2hbulRGMcVZXBxSiFGBWqOZesj 2kVDa1Hi5IM+Eum/KzNuZ1IZjVDybQe79U1np/gNtS0U/Z165z9ACk7HTPD9ndmaQo/8 Dcv8ylrYoND8Wv9erH+RZwUL2mqqvPaKN6nQ1t+Tmw+DmvQW/kabPMQ+/g0UAkOUsxlZ D0CQ== 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=to4odp1EU84jY7NPS+Ne28o7/CevkLRl0Wqah8jQXE8=; b=mUx8PptO4Q4CnTx3T8S1N93Qf5LwuVgs3+2S4YH0vwnW5d5AaAyxZibZiGC4OaMT05 Q4SxiS0rKDpY2vQ/U36nKjkoXJ5SAJHX8nOsikiL2ioJpRO8eJfisK6Ar1JAbkWqb0Yk GCLt5RYPtXKttRdjt98t8bknPh3Qejr9m3wee/JJU1SWaxZ0lzCFn4npzH1C7hpDapEW NVm0bAkjjz6q7TWxYMK+QXNTPPaLWy3082/9ttsNvQ+P6TCKP2nPKCDwUWOIUHv+C/UP QPuyFLvVYa77aTfJWDSACUWaDgRAbRJNR1kJe0ab+350nUO3Zrq2wV8nP+Nl4cUFd7ai qxNg== X-Gm-Message-State: AOAM532Uwz8OIA7+SwGGXbaPIba3ZP9pGhDIbRWLhGgY3vwi+CBcsnl1 8r6AyF6xXbsKwLaZdFqcP7A+BpmXeZDteCLCc5pLySIE X-Received: by 2002:a17:90a:a393:: with SMTP id x19mr16414053pjp.228.1596439526201; Mon, 03 Aug 2020 00:25:26 -0700 (PDT) MIME-Version: 1.0 References: <1908555.IiAGLGrh1Z@kreacher> In-Reply-To: From: Andy Shevchenko Date: Mon, 3 Aug 2020 10:25:11 +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 9:47 AM Qu Wenruo wrote: > On 2020/6/5 =E4=B8=8A=E5=8D=881:46, Rafael J. Wysocki wrote: ... > > +/** > > + * kobject_del() - Unlink kobject from hierarchy. > > + * @kobj: object. > > + * > > + * This is the function that should be called to delete an object > > + * successfully added via kobject_add(). > > + */ > > +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->parent= ? I do not understand. Where do we access it? kobject_put() is NULL-aware. > 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 would > be much better to keep such behavior. Can you elaborate, please? --=20 With Best Regards, Andy Shevchenko