Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1484251lqa; Mon, 29 Apr 2024 09:40:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEfu49TDp/Q7k/gyNkd8OlukMgtRkySXCZKyVpsQHczBSD94praAOFTQrF7sLW5oKMkMqirgZzLsrJLBIsEgy9KcpqYZzGz9TmpOlgcw== X-Google-Smtp-Source: AGHT+IGGn6UukPoxbsR8Mcys1V8ounBnsPl/o7nGV5QyATwxY22X05J5GOZMUjtLCfgis78xKgGf X-Received: by 2002:a17:906:249b:b0:a52:33b0:fcb1 with SMTP id e27-20020a170906249b00b00a5233b0fcb1mr6891927ejb.32.1714408801315; Mon, 29 Apr 2024 09:40:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714408801; cv=pass; d=google.com; s=arc-20160816; b=UubvS2Cl9w0JCRfqOZgkkzjmdf7GdVzhuXKnoTkSdxz+/+lKG0l/NRB6xq+qVWAy+P BnoPilKNbn4ZI8qt9wlSfV7LQQBIbAR8h2mDygLzmDkKBRRvK98OH4r59NQFPdeg4E/k Tt/34On9wZMlBa6UDqvcyfxUjv7J1o2nDisurzqYFbj5M2clcRig5CxjRuNLJihkUrZL vU1LWE9qVBCm48NhjGf6mFuk7SaBanXA6/qVHsU5y4feG+N+cNOWOGqt36Ho3gJBfFv/ CjNIU1P/HQvC++5WZHAy16IWyjS0/84Q+CQInAUjAWwx2xQNAnecf8/AczDUEebY9P1A HEcg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:in-reply-to:subject:cc:to:from:date; bh=WeNz0yR2wRuOaHS15kE7Z2Cd/4PZwy1JL9NDXxKtUjM=; fh=dX0hWIIu9TGtCRTy1aH0se8voBEJC0MpPVA/V1auTGM=; b=P4qoFeL5wbvShPc390KtYXisClxlBWuNEe8CpEcXr6G2e2Opkdr6g0cQh1otFzk/XY y3dTyvri5KfSBa4+iIjRbqTn2FpBlMDSQOuvvEJIf75cQYtC8bP3MQQ5WrSAZ///z+k+ q0422X7I1xfeOxAQtxN5aYhvcp8C9Ub7ubpl2rVo4fZ6hHpICrfjmxutSZYogWES2R+x ekuUc2qZwBn8apjZKai20khJUTV82RoP1udR3CaKqtpxHt5ocvsLIR1+FZb6cMt8+NvY WayHjD6PPNJ+yYwdu/PAOThC9EWPGSdD6jt0clWge9D1kUkshKDFjAcV4QIctOeJIu8/ 0EUA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-162700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qf42-20020a1709077f2a00b00a587ddbd548si8537405ejc.228.2024.04.29.09.40.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 09:40:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel+bounces-162700-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162700-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linux.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0EB641F20FCB for ; Mon, 29 Apr 2024 16:40:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 928BA85C4E; Mon, 29 Apr 2024 16:39:51 +0000 (UTC) Received: from gentwo.org (gentwo.org [62.72.0.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8ECD8529A; Mon, 29 Apr 2024 16:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.72.0.81 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714408791; cv=none; b=tDZKXyCZtI+pgEPWUl/ZAtSZNHqwPFirVObLYX62hj9FB/BDSPlFB/0SOJCbyspElj1fvT0bNsgiBSPhelMw2ek41nmsScoZ0ZMVXP808jgdzvFF3Vj3d5KLzwlyTGGPIIUcN8Ad29F1UKAO04MOBr1Pt4xFEg7oXb6X0HSPy/8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714408791; c=relaxed/simple; bh=Wev12OxkAqraQWDSuLMLLN8uGNu7UeGEQlPZxgQavJM=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=WcOFuevvp1G8T6I5VWe19GHLumRoPMhC4u0ua0ICioea732Z6evyNCUYmd1/e3tJGFYAwl0KzysuIivZU7TWGuHpDzFxl6iHDtue/3QDj19j8ePeJECailxUtKhpXfcbz3RkYYxRvbsBEYMkPo8Nyc/Le9Qs3ywUipNfEXUVFKg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=fail smtp.mailfrom=linux.com; arc=none smtp.client-ip=62.72.0.81 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=linux.com Received: by gentwo.org (Postfix, from userid 1003) id B9A7240A98; Mon, 29 Apr 2024 09:29:58 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id B8E7140A94; Mon, 29 Apr 2024 09:29:58 -0700 (PDT) Date: Mon, 29 Apr 2024 09:29:58 -0700 (PDT) From: "Christoph Lameter (Ampere)" To: Dan Carpenter cc: Matthew Wilcox , Peter Zijlstra , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Vlastimil Babka , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Bartosz Golaszewski Subject: Re: [PATCH] mm/slab: make __free(kfree) accept error pointers In-Reply-To: <571761df-fe50-49e8-8d56-65fbdec9a185@moroto.mountain> Message-ID: <6406512f-12de-1ab6-05c9-4583c0cb01e6@linux.com> References: <285fee25-b447-47a1-9e00-3deb8f9af53e@moroto.mountain> <571761df-fe50-49e8-8d56-65fbdec9a185@moroto.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed On Mon, 29 Apr 2024, Dan Carpenter wrote: > I've always thought freeing pointers that have not been allocated is > sloppy so I like that kfree() doesn't allow error pointers. We always > catch it before it reaches production and that teaches people better > habbits. Personally, I like how free_netdev() only accepts valid > pointers. kfree() already checks for NULL and ZERO pointers. We should add these checks in *one* location. Maybe issue a WARN_ONCE() and simply treat it as a NULL pointer if an error code is passed?