Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4876408rdb; Fri, 15 Sep 2023 15:28:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGlEYKwlk79VZbPOCwCdwbehLaU3MyHf+7FvZ0R5rNAatfKuBGXCOydh76l8hOTOkpy5G7B X-Received: by 2002:a17:90a:c24a:b0:26d:17e0:2f3d with SMTP id d10-20020a17090ac24a00b0026d17e02f3dmr2756436pjx.44.1694816885840; Fri, 15 Sep 2023 15:28:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694816885; cv=none; d=google.com; s=arc-20160816; b=IfqnSCUId3+qfp/ELXAY+BrJZlxr95aPhF8y8cHU9iteEBfUZMlBomKVOUNdKKKBs9 aFSY+iq9zhqUBODGkTJOHRUgj14+NofVJL705QaSDIuNxfBG+WEIwpC06K1U61a83tst CsqYOCpyQ7tmy2FytocdM/2ER40HMp10o6Vll+RYXYclE5NFZKUc7vCBgnvtrTVD17Ai h0fGhqZKyV8TUVKKWBTmacMyMinzphWjWIJTnMafhB5wpmc2f/bL1RUp59/muYo/wy/2 JjBnHOlxlXg86RrNyFu07+Zt8mEplSxetpH+yBsA1K+B0+ybkoWSH2VZJ4JzeYqj/+2X 1nvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zXGgjYhJRVNXafG9EaDgNWKV0uGtY61wiPn89e1hCdo=; fh=c5zw+gyDx14cwIuZDSj2dZInPb/dQnMjXx2jEqO6tOc=; b=OSO5PZMJcQdY4c/sn4YPiYDTbs1SbEJdiIyXE7wYL9pL/TMe1DKDDEBFLi3cqQC5Cg vDLjWnH7hJk4j6wonbpQ9FXgt5Q96JewW/IO6vXXQsQuuqjanE0glWpa4/oCc63AKK4R EX41XhUpS6Guj/xRlHh0OOXvjiPphtTlsq9lEiidAqP2LbxFlIs3rp9FoX907x5Ej1C8 +ZJnMeAlwACb39p5VynHdUh97opI/ZUaPQh3qEBSRm8M+BNTEYq80ZVQmkA9t7LRwGgU 0IbVFE4i7w5vQj5lJrKp+KD1mGpOr1YDvA7/zNLnbcvdBkjJhwf+NFwLY1D0ExGlHu1Y JrIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HgZTrzJA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id g13-20020a17090a128d00b00263f4166a0asi3947836pja.48.2023.09.15.15.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:28:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=HgZTrzJA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id BD2388345656; Fri, 15 Sep 2023 12:07:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237035AbjIOTHO (ORCPT + 99 others); Fri, 15 Sep 2023 15:07:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236823AbjIOTGx (ORCPT ); Fri, 15 Sep 2023 15:06:53 -0400 Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C20FB2 for ; Fri, 15 Sep 2023 12:06:47 -0700 (PDT) Received: by mail-lj1-x244.google.com with SMTP id 38308e7fff4ca-2bfb1167277so40712831fa.2 for ; Fri, 15 Sep 2023 12:06:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1694804805; x=1695409605; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zXGgjYhJRVNXafG9EaDgNWKV0uGtY61wiPn89e1hCdo=; b=HgZTrzJAorYzXFJCksJ2czE4QYLWVP5Ila+LkOps10hKmM0GzRbpdzs6UcYiek0ibn couJWkI9yXTr/igqyH7MclCGq9KPO77unYKKuxrDWe/YcqcIwLfb6TKPLnQBvBM9nrTf styPgbvNImI8/lW0+jpyJz65GEIGcohmWFuFk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694804805; x=1695409605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=zXGgjYhJRVNXafG9EaDgNWKV0uGtY61wiPn89e1hCdo=; b=QONYz+4tj2xScOlVDbRGD1oFGjla26JoCRupEMlKci3Fx92ridtY+HFqsrxdPf1AV8 bavNq6gTYf1DGNqbb1VqwOsNBOrvAEx+h1ca8IkfTNLGNl9S3jNqQxbXh+DmTW8Qns+J z7buPj/L4oQIvfdVGYQKlTc+tZd7NsthETF1tlVyLk88q1oF9r/PStdn3vo3A+rfxaIe f2OO0uyiJMZ4TAWDApzTuYGpzsRo7lsdrzOuSlOJqnryHc9riw4vdCdxabyOcDNYyaw1 p3v9Y91a9Euq19LHdS95WGQHw4t1G+rFD+3BNweANFUtNOcaOQ7I49PgIEaDUEL3WmL/ x/2A== X-Gm-Message-State: AOJu0Yw5k/E1hYenZ8Rus0ICc13zXbMmeU6bDh4FD3hfpzx76S/MTKEh KOgCcekyz9sOXu+/77BLX8FIJktKVMMtEGeALZ+asWfu1No= X-Received: by 2002:a2e:a178:0:b0:2ba:6519:c50f with SMTP id u24-20020a2ea178000000b002ba6519c50fmr2287050ljl.52.1694804805225; Fri, 15 Sep 2023 12:06:45 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id n14-20020a2eb78e000000b002bbacc6c523sm829008ljo.49.2023.09.15.12.06.43 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 12:06:44 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-502f302b68dso1807020e87.2 for ; Fri, 15 Sep 2023 12:06:43 -0700 (PDT) X-Received: by 2002:ac2:4eca:0:b0:500:761b:72ff with SMTP id p10-20020ac24eca000000b00500761b72ffmr2487633lfr.55.1694804803468; Fri, 15 Sep 2023 12:06:43 -0700 (PDT) MIME-Version: 1.0 References: <07c32bf1-6c1a-49d9-b97d-f0ae4a2b42ab@p183> In-Reply-To: From: Linus Torvalds Date: Fri, 15 Sep 2023 12:06:25 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Buggy __free(kfree) usage pattern already in tree To: Bartosz Golaszewski Cc: Alexey Dobriyan , Peter Zijlstra , linux-kernel@vger.kernel.org, Linus Walleij , akpm@linux-foundation.org Content-Type: multipart/mixed; boundary="00000000000047205b06056a7e38" 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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 12:07:52 -0700 (PDT) --00000000000047205b06056a7e38 Content-Type: text/plain; charset="UTF-8" On Fri, 15 Sept 2023 at 10:22, Bartosz Golaszewski wrote: > > IMO this feature has much more potential at fixing existing memory > leaks than introducing new ones. I agree, I should have been more > careful, but I wouldn't exaggerate the issue. It's a bug, I sent a > fix, it'll be fine in a few days. I hope it won't be seen as an > argument against __free(). It just needs some time to mature. Honestly, I think your "fix" is still wrong. It may *work*, but it's against the whole spirit of having an allocation paired with the "this is how you free it". Your model of is fundamentally fragile, and honestly, it's disgusting. The fact that you literally have char ***line_names as an argument should have made you wonder. Yes, we have triple indirect pointers in some other parts of the tree, but it sure isn't a "feature". The thing is, your cleanup function should mirror your allocation function. It didn't, and it caused a bug. And it STILL DOES NOT, even with your change. So I claim you are completely mis-using the whole __free thing. What you are doing is simply WRONG. And unless you can do it right, I will revert that change of yours to mis-use the cleanup functions, because I do not want anybody else to look at your code and get all the wrong ideas. Seriously. So look at your code, and DO IT RIGHT. Don't try to claim that "kfree()" is the cleanup function for gpio_sim_make_line_names(). Because it really isn't. One free's a random pointer. Another returns a complex data structure *and* a count. They aren't inverses. I don't care ONE WHIT if you have learnt to use these kinds of things from GLib/GObject, and if that kind of disgusting behavior is ok there. It's not going to fly in the kernel. So your pattern needs to be something like this: struct X *p __free(freeXYZ) = allocXYZ(); and ABSOLUTELY NOTHING ELSE. So if you use __free(kfree), it looks like struct obj *p __free(kfree) = kmalloc(...); and not some different variation of it. And if you want to do something more complex, we literally have that "CLASS()" abstraction to make the above pattern particularly easy to use. Use it. But don't abuse the very special 'kmalloc/kfree' class that we have as an example. That's for kmalloc/kfree pairs, not for your "char ***line_names" thing. Now, Just to give you a very concrete example, here are two TOTALLY UNTESTED patches. I wrote two, because there's two ways to fix this properly as per above, and use those functions properly. The *SANE* way is to just re-organize the code to count things separately, and then you can allocate it properly with a sane char **line_names __free(kfree) = kcalloc(lines, sizeof(*line_names), GFP_KERNEL); and not have that crazy "count and fill and return both the count and the lines" model at all. The above pairs the constructor and destructor correctly and clearly. So that's the first "maybe-sane.diff" version. It may be untested, it's probably still buggy due to that, but it is what I *think* you should model the real fix around. The second patch is WAY overkill, and actually creates a "class" for this all, and keeps the old broken "count and fill in one go", and returns that *one* value that is just the class, and has a destructor for that class etc etc. It's completely broken and ridiculously over-complicated for something like this, but it's trying to document that way of doing things. For other things that aren't just one-offs, that whole CLASS() model may be the right one. Either of these patches *might* work, but honestly, both of them are likely broken. The second one in particular is almost certainly buggy just because it's such a crazy overkill solution, but partly *because* of how crazy overkill it is, I think it might be a useful example of what *can* be done. Again: UNTESTED. They both build for me, but that doesn't say much. Linus --00000000000047205b06056a7e38 Content-Type: text/x-patch; charset="US-ASCII"; name="maybe-sane.diff" Content-Disposition: attachment; filename="maybe-sane.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lmkytv5x0 IGRyaXZlcnMvZ3Bpby9ncGlvLXNpbS5jIHwgNjIgKysrKysrKysrKysrKysrKysrKy0tLS0tLS0t LS0tLS0tLS0tLS0tLS0tLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDI0IGluc2VydGlvbnMoKyks IDM4IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2RyaXZlcnMvZ3Bpby9ncGlvLXNpbS5jIGIv ZHJpdmVycy9ncGlvL2dwaW8tc2ltLmMKaW5kZXggMjcxZGIzNjM5YTc4Li5kNTA2ZDVkMzRjMDkg MTAwNjQ0Ci0tLSBhL2RyaXZlcnMvZ3Bpby9ncGlvLXNpbS5jCisrKyBiL2RyaXZlcnMvZ3Bpby9n cGlvLXNpbS5jCkBAIC02ODUsNTIgKzY4NSwzNSBAQCBncGlvX3NpbV9kZXZpY2VfY29uZmlnX2xp dmVfc2hvdyhzdHJ1Y3QgY29uZmlnX2l0ZW0gKml0ZW0sIGN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GluZV9uYW1lcykKKwlpZiAoIWxpbmVfbmFtZXMp CisJCXJldHVybiBFUlJfUFRSKC1FTk9NRU0pOworCisJZ3Bpb19zaW1fZmlsbF9saW5lX25hbWVz KGJhbmssIGxpbmVfbmFtZXMpOworCisJaWYgKGxpbmVzKQogCQlwcm9wZXJ0aWVzW3Byb3BfaWR4 KytdID0gUFJPUEVSVFlfRU5UUllfU1RSSU5HX0FSUkFZX0xFTigKIAkJCQkJCSJncGlvLWxpbmUt bmFtZXMiLAotCQkJCQkJbGluZV9uYW1lcywgbGluZV9uYW1lc19zaXplKTsKKwkJCQkJCWxpbmVf bmFtZXMsIGxpbmVzKTsKIAogCXJldHVybiBmd25vZGVfY3JlYXRlX3NvZnR3YXJlX25vZGUocHJv cGVydGllcywgcGFyZW50KTsKIH0K --00000000000047205b06056a7e38 Content-Type: text/x-patch; charset="US-ASCII"; name="silly.diff" Content-Disposition: attachment; filename="silly.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_lmkyu11w1 IGRyaXZlcnMvZ3Bpby9ncGlvLXNpbS5jIHwgNTYgKysrKysrKysrKysrKysrKysrKysrKysrKysr KysrKysrLS0tLS0tLS0tLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDM4IGluc2VydGlvbnMoKyks IDE4IGRlbGV0aW9ucygtKQoKZGlmZiAtLWdpdCBhL2RyaXZlcnMvZ3Bpby9ncGlvLXNpbS5jIGIv ZHJpdmVycy9ncGlvL2dwaW8tc2ltLmMKaW5kZXggMjcxZGIzNjM5YTc4Li5hYzg0MTZjZDk2YzMg MTAwNjQ0Ci0tLSBhL2RyaXZlcnMvZ3Bpby9ncGlvLXNpbS5jCisrKyBiL2RyaXZlcnMvZ3Bpby9n cGlvLXNpbS5jCkBAIC02ODUsMTMgKzY4NSwzNiBAQCBncGlvX3NpbV9kZXZpY2VfY29uZmlnX2xp dmVfc2hvdyhzdHJ1Y3QgY29uZmlnX2l0ZW0gKml0ZW0sIGNoYXIgKnBh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