Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2983733iog; Mon, 27 Jun 2022 06:59:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vG8bcWfq2TSJHQ6Y63Db5m0CoQsHqLx88sI1391LdXZt2fzaF2Hs7wCvQNHasTTyehEDAq X-Received: by 2002:a05:6402:448a:b0:435:3fbe:2593 with SMTP id er10-20020a056402448a00b004353fbe2593mr16574178edb.226.1656338342460; Mon, 27 Jun 2022 06:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656338342; cv=none; d=google.com; s=arc-20160816; b=Mclg/XqVP5tGMCgrrmoGnp/TRqbogpCmRa/cCvW1EiU+Io+EF2Cw9+2foreAylvn8s c13t8PKhtyifOuxlZRDsCSIdYmNZIfz0UbpkLRqN6Nhqot2Wuqu9wqDsNbUVzxzbh4F5 mj8XZ881cp6DuPy4XS+lhT+q1XGOhz7i21GtVYzcMBNHlL/fhlgoYYS0hP4oBLbUZCIK UQNQJjR54eW1d6AhIH28dpdw/9vZ0+E5RvcCGu9h0mnMrcFYipfLIYqH/G2fCqpCNI5N XAk/HpJJParuSpMUBPrM/FoGRyoP1khCDgT8mTy7ozUmfPiYap3LBBFq2nNl/OCr+Wfi wBCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WdTFj4cn8fTRDFRxSeOOVhb6tW1wYiDRpZCHp6VelaA=; b=kDqQNIOzI20powHyigs/8SuxulwLGnn28nH24dSjJTl3fZ7kfoSDYr11vGSThDvECf uzpFfvTbZYjIyLnzhfoLRB+wLQL/yWQVX7l5X9OTanD9l1YOgfuvI9JOflHoDQpeVUgF bVqeA/NokucU+tTPc3Pb3kTGkRBa1TtBtxERiT/IFgJ4frYzq5keRK9Qrw0VQXQTNrXy 4jSFvWaCU69Yr4Oy2UsJqFhqLOXI0N+zieg//hT+4bIKDV/ji5JVAF/9qaHeHG+Vukdb WQstgSew6X3c0p/6ey2pdu8Ws5S1uQavkwa8b7l3Tz4FnzYJTYYK/0tDvJ+3XOqnLmtd 2WLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EJv1ybgj; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb17-20020a170907161100b00707dfcfc53asi11054067ejc.411.2022.06.27.06.58.37; Mon, 27 Jun 2022 06:59:02 -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=@linuxfoundation.org header.s=korg header.b=EJv1ybgj; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235612AbiF0N0s (ORCPT + 99 others); Mon, 27 Jun 2022 09:26:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235554AbiF0N0r (ORCPT ); Mon, 27 Jun 2022 09:26:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7BCB63FB for ; Mon, 27 Jun 2022 06:26:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 66040B801BF for ; Mon, 27 Jun 2022 13:26:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6AC6C3411D; Mon, 27 Jun 2022 13:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656336404; bh=7MsHUpxL3zsu4LKADachsIvoM5/0gKY0VcnodHp7Fuk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EJv1ybgj9PDuO4LIafSqlxRZza1F9s4ECfdY+BZ4swTQNUH3twQpw4rupAiV5KTPm /01V/j2gwWA0CKxmECK4I9adJ/P/Jwr7b//ij5pkRWltedk8TWV/aPmdEeKvTwggih 9rXuOfmoYOnNVzAdX16w0LYF1D9LZmrOy22MA8Y0= Date: Mon, 27 Jun 2022 15:26:41 +0200 From: Greg KH To: Zhi Song Cc: rafael@kernel.org, Jonathan.Cameron@huawei.com, kbusch@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4] node: fix error handling in node_init_node_access Message-ID: References: <20220621171623.1959231-1-zhi.song@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220621171623.1959231-1-zhi.song@bytedance.com> X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 On Wed, Jun 22, 2022 at 01:16:23AM +0800, Zhi Song wrote: > dev_set_name() allocates new space to dev->name if it allocates > successfully. But if we failed to allocate space, there won't be any > new space for dev->name. Therefore, there's no need for calling > kfree_const(dev->kobj.name) in dev_set_name()'s error handling. Can you actually trigger a failure in dev_set_name()? I ask as we don't seem to check this anywhere in the driver core, and we should either just not care (as it really can not fail), or fix up all instances of that failure. > If we failed to calling device_register(dev), we just need to call > put_device(dev) which will do access_node freeing, kobj.name freeing > and other cleanup. That is a separate issue, and should be a separate change, right? thanks, greg k-h