Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1711304lqa; Mon, 29 Apr 2024 17:43:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWIUbvQ4I53bP7md4cNsu6d2aGHk9IiYTTh5UYucUhyyxTHgU9u04HHNdRd+M5wUAmTYSnPPG7uwc3VIQlfWrDA1cdoj+HcQi//mO96QA== X-Google-Smtp-Source: AGHT+IFWf6Gbf9q0BE43BEO5TwiTbHDrrMYopVq6uGzAvpSN17534JmdXA6XiSB3iJ77xnx0e1Dk X-Received: by 2002:a17:902:a714:b0:1e0:dc6e:45d6 with SMTP id w20-20020a170902a71400b001e0dc6e45d6mr12018652plq.60.1714437779883; Mon, 29 Apr 2024 17:42:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714437779; cv=pass; d=google.com; s=arc-20160816; b=ir0IKBtyosXreFtawP3zDY0TYgW5v1Zd9QhsEV60y3VaUeYXalWzjDOc5iuZa1W3gx ZHy6+5HA1TuEL1z0mNog97o2/7ePENCqO5qLZsgH1vlZbP2PtRKlpTgJAPi/59DtaJ+F wD/UkG7i7UhhV3tT0o3olQQKRxM1uOjimlt2rlXfri+Oy1BdHY+52ZaFGIfk7D6N9GqQ nMZkxaICdikXPWBI8/63bPllvYiS166ObqYRyS6Iqv1VUMQxaaoeJqHrml4UTzynXy5d EgByFvCWV4GcNHj+rhv6CDbD9YjHKX/1nlwFKW3dI2ixfDbMD7cYESG7ykxX3h9mMNeI zVvQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=jC6bSyr5oonwWrDWbGBbEJAkPCiv04wjoLO2Q3L5KgU=; fh=7zQFLap8VPCSqJLb7Pv9V1ezbKX6YqzKtgDJ7NQeZEw=; b=fUYpDlKK/1Y1bcEYM481STM9p0cUTS7Rq1aJxMB7/hAxx2XNIcCISl5SCj/EWLC+3V +faYHKl9Vq+fjnmjXneE0SLT1+iC5Dm6tpIFxLJ3il6caVQ9QfdA5O+c/DQiegU4te1a fXwEtNGkKMZrdUVwzer+DnuNQzfmKcVEZ+FpjFlG+rXZU37tJ+CEH5RpGSYAaqlIJv8d fWOx2RafnHus1u/Ci+w6h+hJ75NqrSsuyBM+IArxE6VLOpU+XdbMfNoDie8BE93sqOtP mqJXNTfaqtyVhZgfP5kTVEzp7MMNTgAGoBkJpT1+p5olnipqtJyaMSc5rl4LwJyDj6lj p0wA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=DknZsuwz; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-162832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162832-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id s9-20020a170902ea0900b001eb70eb2853si4649485plg.96.2024.04.29.17.42.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 17:42:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=DknZsuwz; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-162832-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162832-linux.lists.archive=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 647E6B2150A for ; Mon, 29 Apr 2024 18:34:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0937C12A15A; Mon, 29 Apr 2024 18:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="DknZsuwz" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 D9E4883CBA; Mon, 29 Apr 2024 18:34:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714415675; cv=none; b=WMpnFF4Pr5FWNisy3Xrk9udVT/1sI+9NDsp0VtwwmAmN7BbEXYsZfQX/nTgSjuQQ20AzkM0TVL8kqR5JKDvEfWx5P1Y30ekgdH7tS36m9sto9XNWOVW5exjQ4L++/rNRGG+R0Sbq5ASnUKudUI7kHaI74oxc55cEHBoW553YjZc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714415675; c=relaxed/simple; bh=lDZGWAziRokGy+VN6nOa0Kj92phXfS5Zq58Fyuy6tQA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aQtf2rmE4wLLgcSiiflfAQTJ72zl+NAWtkBLEcwMmw8IOgeeGqmsUMB+IeLJBaduHDVvgNHlcZm0H9RvZSoDigLmVhTMAx4sOtTLQANTzrRgMTWx0X53Me2Mc9UAw9ZAAoZNJ1B65eYvvUCOTqdwD9DKgLpyxzUr8e6I6RMqKaE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=DknZsuwz; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=jC6bSyr5oonwWrDWbGBbEJAkPCiv04wjoLO2Q3L5KgU=; b=DknZsuwzHHHEgR7uIz155aKKoP muMbKntDvFIhGVgxlwB1C3G37ruqpiueUsgPiHrKoEhreK3riyfPmzgWGNjgs1wFl0IlCa0vfZnM1 jTsbtPZUkATj20Fw7uE3hFa/uzFsAEXNYsvL6WZiAl+WgFMN8urqS1pj73wY2OXulo4c2jbFpI8z0 eeLeLq8GYnZG1TqcwORanP2M47MM59gYy1PSaHDKRPnl0ObM8dH3IYSbvW8dAdfcgVVjhADuAU6g9 ZMUqox2L5PCr3y+RdssQKDID7ATf7KF/C4zvM6HwGrKKZrBAZvUr0jQVWnn3JXZBHWJHZKggn+1F7 6t/VgbWw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1VpY-0000000D53Q-3aYH; Mon, 29 Apr 2024 18:34:24 +0000 Date: Mon, 29 Apr 2024 19:34:24 +0100 From: Matthew Wilcox To: "Christoph Lameter (Ampere)" Cc: Dan Carpenter , 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 Message-ID: References: <285fee25-b447-47a1-9e00-3deb8f9af53e@moroto.mountain> <571761df-fe50-49e8-8d56-65fbdec9a185@moroto.mountain> <6406512f-12de-1ab6-05c9-4583c0cb01e6@linux.com> 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 Content-Disposition: inline In-Reply-To: <6406512f-12de-1ab6-05c9-4583c0cb01e6@linux.com> On Mon, Apr 29, 2024 at 09:29:58AM -0700, Christoph Lameter (Ampere) wrote: > 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? Did you even read the initial patch? The point is that this new automatic destructor path can pass error pointers to the destructor for completely valid code. Warning would completely defeat the purpose of this exercise.