Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4997370rdb; Fri, 15 Sep 2023 21:26:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrXimqs7ScW3m/dJ1URyzvVTARhDuoeKXGqKhqXLWpvdvqtfazjTu8P7dmrGVLhbzfg63G X-Received: by 2002:a17:90b:3756:b0:267:f094:afcf with SMTP id ne22-20020a17090b375600b00267f094afcfmr3226302pjb.12.1694838387110; Fri, 15 Sep 2023 21:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694838387; cv=none; d=google.com; s=arc-20160816; b=xJgVnDAldBbo24L3qn/0/Yor4JhbdMFyOJXOa0iX9mgRwRaoHXS4kpgQVBiKEzfYDj uaWlkU9uFHvZiw6ygkLocuKMS4RnLmoN6fpDM67zFLcRD1p4TXa+UZgE5JL0J+xsBJxN 7HOyzTcDhz0fGXCOp1xyMweKMYjYhTfif3PlTC54PS9bGyHNONKwhFggDjtznicleqsu yQ4WzSJBegriig9b4hy2JRCJWOAt+lGqgNYwAko88fWIxQm05Oph7HCDoHeG4DzVPErO 3L6YAfB+K7QXwdmGc+RU1MzeZBXtcP/BBjsQzqremGX/Qu4hb46lGTV68f6q3j1nk+3I yA1Q== 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=TNJXGjMWE/z4uo7zMO2zo9L7xP/mpflLJ9YjyGlxZWQ=; fh=0T/Cz/6kfzyq4MPg6wrhuDkAsXxv4Wnv+2jNEKRU/s0=; b=L58cyb/88yabCnmp+dWq/EjFpgYsOftPOeQVnEovRazhcMickCkKQdih58KMUcrfo3 G9Ysx9JJAhIJTDx6L4btDy9Cv213QdyahsOMD9rxpRPV9kaO/DK5TffCEprkaG3hWOnN DDYElZdcQfcx2/Xy4eJZF5zKzhIoun9mhsDb7oh0O1CYgu4y2bDlw1TOezhUjgc7lb9R kEQV0Hu3U5g/Tys0Fu81KQsS2upK6+HG12C+w/z5iuu8Q6/7SxmFApToAhmKh3BHRta2 YlsxxuOnaZ1LJ6wni8gUEAe88syKFpw89c4Sadc0MAU4FPRRlitJeVH8YZ6lD+MiP/WB +5yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="Oa8/8eGG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id i10-20020a17090acf8a00b0026d4e16c957si6493174pju.77.2023.09.15.21.26.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 21:26:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="Oa8/8eGG"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E738D829E6ED; Fri, 15 Sep 2023 14:33:26 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236136AbjIOVc4 (ORCPT + 99 others); Fri, 15 Sep 2023 17:32:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237768AbjIOVco (ORCPT ); Fri, 15 Sep 2023 17:32:44 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA5FB8 for ; Fri, 15 Sep 2023 14:32:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=TNJXGjMWE/z4uo7zMO2zo9L7xP/mpflLJ9YjyGlxZWQ=; b=Oa8/8eGGCgHuh32pBkKAscfMiA yqNpxiMy1t+B1AH3qYjuv6yHGTxa7THIt9MxnAAseRYeNZUQFjQO76SO+MYL3iCVa1moKoKYh7oFO n7VfIRSSIlZjQ7jTPbw0KMaqs+TJ4/lfbEWb7lxPDjr7euIYlVUrR0phbribVZfSzgF/OZpH1Guqo HsgE0Bq4PTRDquhldhLdyJovfwMInE08LMaJFMebgIM7J/AQ2V6wHNpcxjj5791vc7WyAXXhmvGi0 fToLVGg1oziP59ko7QOkSWXN5hF8+8Lh+7rFO/13rCN1xiYN5sTWi6Bl6KFNaGmaGCg2wzU8RvrLx TXJEjOkw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qhGQQ-009bQ8-2f; Fri, 15 Sep 2023 21:32:32 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id E39DA3003F2; Fri, 15 Sep 2023 23:32:31 +0200 (CEST) Date: Fri, 15 Sep 2023 23:32:31 +0200 From: Peter Zijlstra To: Linus Torvalds Cc: Bartosz Golaszewski , Alexey Dobriyan , linux-kernel@vger.kernel.org, Linus Walleij , akpm@linux-foundation.org Subject: Re: Buggy __free(kfree) usage pattern already in tree Message-ID: <20230915213231.GB23174@noisy.programming.kicks-ass.net> References: <07c32bf1-6c1a-49d9-b97d-f0ae4a2b42ab@p183> <20230915210851.GA23174@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 15 Sep 2023 14:33:27 -0700 (PDT) On Fri, Sep 15, 2023 at 02:22:02PM -0700, Linus Torvalds wrote: > Naming is hard, let's not make it worse by making it actively misleading. I actually did use the DEFINE_FREE() helper, will go fix. Because yes, free is not the right word in this case. > And honestly, I think the above is actually a *HORIBLE* argument for > doing that "initialize to NULL, change later". I think the above is > exactly the kind of code that we ABSOLUTELY DO NOT WANT. > > You should aim for a nice > > struct rw_semaphore *struct rw_semaphore *exec_update_lock > __cleanup(release_exec_update_lock) = get_exec_update_lock(task); Ah, that might be nicer still than the class thing I proposed in a follow up email. It also got me thinking about named_guard() for the myriad of conditional locks we have. named_guard(try_mutex, foo_guard)(&foo->lock); if (foo_guard) { // we got the lock, do our thing } or named_guard(interruptible_mutex, foo_guard)(&foo->lock); if (!foo_guard) return -EINTR; Are these sane patterns?