From patchwork Sun Sep 17 09:12:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 141136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2044364vqi; Sun, 17 Sep 2023 02:20:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELuPYRvZjdeW8ALXwTgbSyYMFooAnCHTlbtgfQrmKyFTBENzcuruMwI3Zf7En8poxI4fMg X-Received: by 2002:a17:90a:6e04:b0:268:1b60:5031 with SMTP id b4-20020a17090a6e0400b002681b605031mr4528386pjk.12.1694942413491; Sun, 17 Sep 2023 02:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694942413; cv=none; d=google.com; s=arc-20160816; b=KkjKqSaTqOuZ/uFgJDLD8vWc+4oUIngWRcbFgzHf3MsULvFugLZrse5sBPbPhTgnuv UspUGGhJK4Jki5cfrzuYDSQzCIqoR+ZO0Hkm+9LIPeXdC59iJrbNNaAYjPplJZb85DaY Pvsl79W+qDOSVERXLecnhWukVqT+OQRB7JLDgKWpfwafDT59DEW+2LTlyiCbdaVJm/J9 gYK/dcJuVuI+oc8D9eujP/0IT9RCoStXXe8252S7FmSIhY6szf0BJEg+Ag7QDvu28Zum 4R9UfgnUjCbUbKxRkb4EMAJnCPmuQhL+lIP67dskym1dtLrt7wSDQx8BPEO+nbTVIaVj fjjQ== 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:date:subject:cc:to:from :dkim-signature; bh=1MJIm7l05TNgBD7fIZpFbmCq3yhWvKvp7t4WFx7t1Es=; fh=lCwMbqetBpO0Vd7a3gKFArRnLB2AASuTMycQRzK1uok=; b=xNbPokeH+HwQ/4U1VP/ojmIZlwrpzu9pM3lvoIfOav6Czddf1Q0RtEr9gXILNQvvga pjlyXGLZz6moDbyVBwEwybzPpyPsy9ip8Jv73baC+38CH2u8a0I50xyLqj4465l8EBYP VfyM8A1ZPvPbCY7P7gtQ5lUUuZhle2hIqCexbkyooWvhdJu+o1BKb1SBb+gMv75WN/OJ 4vmCh616DS9i+htLNeRxNDnulG6WmTgi4XuUCzEF2qNTtlFjBowQQlH2i0G8LO8hPWvI 3iPsgy2zMhaDSwFMmJPjbk0jhWs+YFLu8+S4rfcsIj+XBv4zU6ztvyVhrfGWZGQQhcSr qVHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=YUxwIP+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id u13-20020a17090ae00d00b00274ac0df61bsi3245381pjy.122.2023.09.17.02.20.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 02:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=YUxwIP+g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id CE7EA81DF762; Sun, 17 Sep 2023 02:13:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235667AbjIQJNE (ORCPT + 29 others); Sun, 17 Sep 2023 05:13:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236104AbjIQJMn (ORCPT ); Sun, 17 Sep 2023 05:12:43 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 716D118C for ; Sun, 17 Sep 2023 02:12:37 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-402cc6b8bedso40381335e9.1 for ; Sun, 17 Sep 2023 02:12:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694941956; x=1695546756; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1MJIm7l05TNgBD7fIZpFbmCq3yhWvKvp7t4WFx7t1Es=; b=YUxwIP+gcHNUi8WcBPft7GNx27/mR/hARGdlGtX7kN023f4/tuJtgWgoYllFPnTsKe H/hnJsOOtWjt6aTwig3N2zP2ZxPU2H27goXfLI5nq/G+YgCXt0686/1F1ZGcY0f5PTp5 RNMjcIRYl98ETI1YJn/WtiHDKI6K6dB9p/rUqsHmFq02Ob+qZTzg4R/3gEAHOtDLmuKC nCEXHtxhKFxWgX0BuqVJd6dqOQbngnLlVZDwELCC4B1+7gFMHAa91yfrwLsWRuZZO7r8 nlea19n4zOak2Jeu37XMy09FphF4UZ6B5AGHQvT1OAb3Nzq9+YIWm7AbPyZiHfzI5xfc ZzYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694941956; x=1695546756; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1MJIm7l05TNgBD7fIZpFbmCq3yhWvKvp7t4WFx7t1Es=; b=A3njAZ9rIrXtWO8A2zTMny2EYBq95a0ngBX77pIEMeDfW6oafPL6tfnz2Ab169rPNd /oYsHIZBnLEekETjS6YitV9CVWb+WfuOCb+KyCq5Nvw0GYfFs6xsacWUnc+w0AXSQo83 vyXT7qKceK3vfZM6G0uUdk25f5bUPC4zdqneyM4nqqlnoSpmNM1SgrvIyfmZsHYCkfu+ Ve9OvRG7pXJ1V2yZXv6jkZ8NPGGN81hDQx2YAz/CggP2RJ8sPDzG0qap6nK4O2PlDQxb tmdskIcTFOGWqltUsT5dSJavGtkyZRrWGGmGYEraV8WwWFiBsZIkmp0/I89GD+5ZlD1d LZSw== X-Gm-Message-State: AOJu0Yw1U3kKUwxfVwamtu04YsktWMIQh4YhhOQff9185lOrJVI4X+hQ Iz224/SL2yaDhSMu6zuY8y7qww== X-Received: by 2002:a5d:6dcd:0:b0:317:6a7c:6e07 with SMTP id d13-20020a5d6dcd000000b003176a7c6e07mr4214828wrz.32.1694941955766; Sun, 17 Sep 2023 02:12:35 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4ea0:9945:6800:8739]) by smtp.gmail.com with ESMTPSA id r8-20020a5d4e48000000b0031ad2f9269dsm9099688wrt.40.2023.09.17.02.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 02:12:35 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson , Alexey Dobriyan , Peter Zijlstra , Linus Torvalds , akpm@linux-foundation.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 1/2] gpio: sim: fix an invalid __free() usage Date: Sun, 17 Sep 2023 11:12:24 +0200 Message-Id: <20230917091225.6350-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230917091225.6350-1-brgl@bgdev.pl> References: <20230917091225.6350-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 fry.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 (fry.vger.email [0.0.0.0]); Sun, 17 Sep 2023 02:13:41 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777275936150898483 X-GMAIL-MSGID: 1777275936150898483 From: Bartosz Golaszewski gpio_sim_make_line_names() returns NULL or ERR_PTR() so we must not use __free(kfree) on the returned address. Split this function into two, one that determines the size of the "gpio-line-names" array to allocate and one that actually sets the names at correct offsets. The allocation and assignment of the managed pointer happens in between. Fixes: 3faf89f27aab ("gpio: sim: simplify code with cleanup helpers") Reported-by: Alexey Dobriyan Closes: https://lore.kernel.org/all/07c32bf1-6c1a-49d9-b97d-f0ae4a2b42ab@p183/ Suggested-by: Linus Torvalds Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-sim.c | 64 +++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index 59cba5b5f54a..7d52f7caa1c7 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -718,52 +719,42 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page) return sprintf(page, "%c\n", live ? '1' : '0'); } -static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank, - unsigned int *line_names_size) +static unsigned int gpio_sim_get_line_names_size(struct gpio_sim_bank *bank) { unsigned int max_offset = 0; bool has_line_names = false; struct gpio_sim_line *line; - char **line_names; list_for_each_entry(line, &bank->line_list, siblings) { - if (line->offset >= bank->num_lines) + if (!line->name || (line->offset >= bank->num_lines)) continue; - if (line->name) { - if (line->offset > max_offset) - max_offset = line->offset; - - /* - * max_offset can stay at 0 so it's not an indicator - * of whether line names were configured at all. - */ - has_line_names = true; - } + has_line_names = true; + max_offset = max(line->offset, max_offset); } - if (!has_line_names) - /* - * This is not an error - NULL means, there are no line - * names configured. - */ - return NULL; + /* + * It's possible that only the line at offset 0 has a name in which + * case max_offset will be 0 but we still want to allocate an array + * of size 1. + */ + if (has_line_names) + max_offset++; - *line_names_size = max_offset + 1; + return max_offset; +} - line_names = kcalloc(*line_names_size, sizeof(*line_names), GFP_KERNEL); - if (!line_names) - return ERR_PTR(-ENOMEM); +static void +gpio_sim_set_line_names(struct gpio_sim_bank *bank, char **line_names) +{ + struct gpio_sim_line *line; list_for_each_entry(line, &bank->line_list, siblings) { - if (line->offset >= bank->num_lines) + if (!line->name || (line->offset >= bank->num_lines)) continue; - if (line->name && (line->offset <= max_offset)) - line_names[line->offset] = line->name; + line_names[line->offset] = line->name; } - - return line_names; } static void gpio_sim_remove_hogs(struct gpio_sim_device *dev) @@ -867,7 +858,7 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank, struct fwnode_handle *parent) { struct property_entry properties[GPIO_SIM_PROP_MAX]; - unsigned int prop_idx = 0, line_names_size = 0; + unsigned int prop_idx = 0, line_names_size; char **line_names __free(kfree) = NULL; memset(properties, 0, sizeof(properties)); @@ -878,14 +869,19 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank, properties[prop_idx++] = PROPERTY_ENTRY_STRING("gpio-sim,label", bank->label); - line_names = gpio_sim_make_line_names(bank, &line_names_size); - if (IS_ERR(line_names)) - return ERR_CAST(line_names); + line_names_size = gpio_sim_get_line_names_size(bank); + if (line_names_size) { + line_names = kcalloc(line_names_size, sizeof(*line_names), + GFP_KERNEL); + if (!line_names) + return ERR_PTR(-ENOMEM); + + gpio_sim_set_line_names(bank, line_names); - if (line_names) properties[prop_idx++] = PROPERTY_ENTRY_STRING_ARRAY_LEN( "gpio-line-names", line_names, line_names_size); + } return fwnode_create_software_node(properties, parent); } From patchwork Sun Sep 17 09:12:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 141151 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2162109vqi; Sun, 17 Sep 2023 07:37:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFICKb7vfqeXuZan5g0+ew6lTBS/B6fQzQ2vv4t09yJ/DuwRMrg63tcVQTcuikcKAxHSvTQ X-Received: by 2002:a17:90a:ca14:b0:274:7db1:f50f with SMTP id x20-20020a17090aca1400b002747db1f50fmr8860045pjt.15.1694961428009; Sun, 17 Sep 2023 07:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694961427; cv=none; d=google.com; s=arc-20160816; b=tD+7+qQDaWnJ+z0Ae1kPjoUoeY2HT91UyTN8UGLeV6YUnw0OQTM1IZUkPMbPYr/Lez 1evcOzXC7IYXmxeCyxNPVCyFssHtTjC5paRP1rHH/vGOaSpBcyFRIWcTmYyJs+RuYhi4 uiagqGXsLEi1Jevq5RKO5Tydv/FlwqlR0UG/B2iS7dpMCUhO/w5QTnabFkc/LD+kZ8Xb 8fh1EdL+gw0LkTplp7nu1Luzp8+1A0vW/36pdPjnbvuQIUwY+rkM3shc4Dwj2H3Q2lqu 5v82amWOk+JNuKAU8/zccbW2wV6mQ0N4Gyo8TBmpTcSv+89921Pvhi33u8Qoo+krvNGU 1oMQ== 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:date:subject:cc:to:from :dkim-signature; bh=gLx97nqlGktbTFj4ow2g38C1r2nkF/YD/yvv8rbu4tY=; fh=lCwMbqetBpO0Vd7a3gKFArRnLB2AASuTMycQRzK1uok=; b=RSvKAF6nSuIM71rZoPCPQjat2tYbibRQdVyhdmInRf8oDL5UCNTBArJKlG1AXYjjMS qUdHHm5f6JDyingCzZwCHnMde/KcFoHgIoL77u7DeyAtnfX77qM2eIxKhgtruKDPGRK4 stq/NUi2H9RiTUe+JP5oTfYKS2/UHY2OONweTPTrJSzzJsirwGrja/2Jrlj+Q2tRi5Ve ZtUP7PbRB6cC/JdCiRQxUTj6Vyqjr4+AK8wthPTFag4ONAoRCAmhv94PoWcSqh1rfw1b 4CO0DY8RPSESLL5lE3D42wg+BZC3OP0doU2QmSw5F2h3rp3/nOPea9KeSbkgNqZdkLYq 7H4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LRE82rMU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id h22-20020a17090acf1600b0026cab818aa2si8670470pju.100.2023.09.17.07.37.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 07:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=LRE82rMU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id B4BEF8023926; Sun, 17 Sep 2023 02:13:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235359AbjIQJNC (ORCPT + 29 others); Sun, 17 Sep 2023 05:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236133AbjIQJMo (ORCPT ); Sun, 17 Sep 2023 05:12:44 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD02418D for ; Sun, 17 Sep 2023 02:12:38 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-31ffe67b5daso1093650f8f.0 for ; Sun, 17 Sep 2023 02:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694941957; x=1695546757; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gLx97nqlGktbTFj4ow2g38C1r2nkF/YD/yvv8rbu4tY=; b=LRE82rMUJdPy0ijzGNRZj1Gaoo6bq4kK+iDNvkNtR+TSi9UcdgMqwJnk+CRUiVAVuO EQqVGvERfyqQowlT1O+fSStDtJ6o9oqRViG5MRAp6/PscyXT1qEsD1LYPS/8NS8d5Mnd MO5FohwNg71lEOw9vdrNS6biBAAh3lPSfG28oQbL6WndPopkuJuvqwKi86zq5SSap9LC X4Ge+FerXgtF/RkBN0F5YvjFeEJqsDQXxAX5lPafyzq9Upyu3MFukLLmG0c8WRoR+xby bxeZ/7y8EK4Y+ExShRVQvkfn8gYQ1Vv8Q4IvGV23RUWMyXRrMB5EBhXeDsLMB7IwGhAP spYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694941957; x=1695546757; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gLx97nqlGktbTFj4ow2g38C1r2nkF/YD/yvv8rbu4tY=; b=XNpaDfVcjk7F7ThL8o88jahKUMW/ngahRX2psGRlRXMBf2sZdhu2naC2XdV558P3ZY VMjBxBhyKJvp0pNrb2BTphl8nsl/l4/MSQklBdYU6/JTke4fAaUKA9LmzLT1qCIDe34S 1syhqL2EBgpL5hgJrdTa7RFwIUGEDL7lMkLzQYjdRUUNQr3+OguTU21ne/z4bGyCg08N iXIcCG88VoE50VxlfNrp2+V4oNTm4Eu+MAmSjNn87t/d15sXL7Jh7NJXaV9p/Nuji5jV 6YvyEMj19w21W9qcoBz8d/0CBi/1CIVzWkKAwuhSPjeVz/sD+EF0eEwZBTClI6Dh1P3U 55BA== X-Gm-Message-State: AOJu0YwKHqsHNCnSugj5rNO3nBLod4/0lBM5GDaxdohQxS3TkVcEAI5Z Khwu1B0nIzFLcu9gpjkaslHT1w== X-Received: by 2002:adf:fb52:0:b0:313:fe1b:f441 with SMTP id c18-20020adffb52000000b00313fe1bf441mr5017807wrs.29.1694941957144; Sun, 17 Sep 2023 02:12:37 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4ea0:9945:6800:8739]) by smtp.gmail.com with ESMTPSA id r8-20020a5d4e48000000b0031ad2f9269dsm9099688wrt.40.2023.09.17.02.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 02:12:36 -0700 (PDT) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko , Kent Gibson , Alexey Dobriyan , Peter Zijlstra , Linus Torvalds , akpm@linux-foundation.org Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 2/2] gpio: sim: initialize a managed pointer when declaring it Date: Sun, 17 Sep 2023 11:12:25 +0200 Message-Id: <20230917091225.6350-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230917091225.6350-1-brgl@bgdev.pl> References: <20230917091225.6350-1-brgl@bgdev.pl> MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (howler.vger.email [0.0.0.0]); Sun, 17 Sep 2023 02:13:30 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777295874553918800 X-GMAIL-MSGID: 1777295874553918800 From: Bartosz Golaszewski Variables managed with __free() should typically be initialized where they are declared so that the __free() callback is paired with its counterpart resource allocator. Fix the second instance of using __free() in gpio-sim to follow this pattern. Fixes: 3faf89f27aab ("gpio: sim: simplify code with cleanup helpers") Suggested-by: Linus Torvalds Signed-off-by: Bartosz Golaszewski --- drivers/gpio/gpio-sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c index 7d52f7caa1c7..1a8a332a803b 100644 --- a/drivers/gpio/gpio-sim.c +++ b/drivers/gpio/gpio-sim.c @@ -1481,10 +1481,10 @@ static const struct config_item_type gpio_sim_device_config_group_type = { static struct config_group * gpio_sim_config_make_device_group(struct config_group *group, const char *name) { - struct gpio_sim_device *dev __free(kfree) = NULL; int id; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + struct gpio_sim_device *dev __free(kfree) = kzalloc(sizeof(*dev), + GFP_KERNEL); if (!dev) return ERR_PTR(-ENOMEM);