Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp699578pxt; Fri, 6 Aug 2021 11:29:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyvczv92beJAB0DCz6Q2WFVV4scTzVH15W/qwlbjg4bUdgfKo466/4RqEqKe5UUIvyeecO X-Received: by 2002:a05:6e02:1c88:: with SMTP id w8mr193702ill.154.1628274574741; Fri, 06 Aug 2021 11:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628274574; cv=none; d=google.com; s=arc-20160816; b=UZJqnEexPd/3Bjzq5O3P2lUFSx6GlQJ+9RZbIOLNcGKhyEam9J7whxrcA0DKyK29k1 E51WTHMUSupPDDIIKWrhyEiZizH42CMMwGJ/W46QWZf/uM4exuAv5Zb5dURslcRJKEOF 03jSp/ItdzAX9qmwXoIm7YjTN2hGkP9pg9I7s9JXo28Ef9NTCs5cbPq1qxkN3UXE17qC Q+sIprtHErLYpQ7rKcN2/kX/o+QJ7EYNu4xh8FkfXxbWNbFnT/BFY52XdVcgNfIVyECA Ds8/IHo1Fklt8S0TaCuDsZ1F0YizqL0iTO2c6BlKenm7yN9K26IZcDPg4EvQX4JhSjcZ KQ5g== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=eYQxNxDJ1Fyai3Fhc+dBthoQualfeQuRZGxJqgRMiFI=; b=M4QOBOCP/VvaXWh98I8GONZFhQhhSyT45EYoqN0HK9QMlMhaS5GfRDEF5dgyXJsPxL wzXlsE46pnjXeNadVOum3IatNqmzZJELdgRgXhSXslOcMTjYqfVx/MUQGt+9u6LRLroZ ulWp1YZQqHLTwo1mLWQr/5CeubSZFBu7YifraG4qgLUisLZnYdJXFtzAfhhfm4WNNbRt tQqi7u/QmlvDF+0cfoBOv3n/KqpqmnBX91YTMuocWFzXHRu2jxSTTMighmGPJVyyhx9v K4WZhiRnjQvhwIOSYhfgNvEQAbZQIlcN4mh7QLlLmG42IWkojjgj7hEaIXbSJTeY0Qf6 AuQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j6nSVj1E; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n12si11107848iob.52.2021.08.06.11.29.22; Fri, 06 Aug 2021 11:29:34 -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=@kernel.org header.s=k20201202 header.b=j6nSVj1E; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243957AbhHFNM1 (ORCPT + 99 others); Fri, 6 Aug 2021 09:12:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:36678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231388AbhHFNM0 (ORCPT ); Fri, 6 Aug 2021 09:12:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A3999604DB; Fri, 6 Aug 2021 13:11:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628255497; bh=Tr1IB48QyqqZw+MLNXRX+N03dm0H0jBEHbZKl+s5DGQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=j6nSVj1EL2bF5suI3OHAKFiK25b7bGsMTEh7hW5r2H/f5cAfFK7CEep5Ztgf5ycVF BalSx4PxAFW+/aBlEh53ddRlb65p8ksc9tfEh080Wrl6yNOmHcpXsHzJAMHPzPCEuC TMqNiTGXsqYQ/ZJ4AH+bz99Y+eI1TVeo2/X1Ct7PZpX9Jxg7hJrVpdlqNx9CFF5aET 6H/YiEcj1TASb6dgy7WMezaPjLBA318R4aC+2nJ3LH2jT08ZQ3YyILiOHWmYD8yLTz gapSxovbkTrSozFh03F2vsE2JL01QDuW0Th7QdQrDyOAfbChpiCTI/PaFlNRPMy/Kf hYh0WLOdoz/OQ== Date: Fri, 6 Aug 2021 06:11:36 -0700 From: Jakub Kicinski To: Yajun Deng Cc: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] net: sock: add the case if sk is NULL Message-ID: <20210806061136.54e6926e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210806063815.21541-1-yajun.deng@linux.dev> References: <20210806063815.21541-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 6 Aug 2021 14:38:15 +0800 Yajun Deng wrote: > Add the case if sk is NULL in sock_{put, hold}, > The caller is free to use it. > > Signed-off-by: Yajun Deng The obvious complaint about this patch (and your previous netdev patch) is that you're spraying branches everywhere in the code. Sure, it may be okay for free(), given how expensive of an operation that is but is having refcounting functions accept NULL really the best practice? Can you give us examples in the kernel where that's the case?