From patchwork Sun Sep 17 08:58:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 141145 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2110391vqi; Sun, 17 Sep 2023 05:36:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEWNC0xle06qZr+1L6jFNJXBYkXTldiXRmUMFLQaLG6+4Z+aKgn6F4IxsItN+B9iAXH0yf X-Received: by 2002:a05:6870:638e:b0:1ba:989b:ca65 with SMTP id t14-20020a056870638e00b001ba989bca65mr8450041oap.19.1694954166435; Sun, 17 Sep 2023 05:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694954166; cv=none; d=google.com; s=arc-20160816; b=PP7bk5Hhn+4XuojRh9rcXOA+cGbQXhpKpAUbJsbOEEPJhM5a6Qojmsh9aRByNas24M iD39HM51CoYwyLOBVmw+GLvB9sa0MhsWBkiKISxiaDDyuv+N1Ga8ObGRtOJoGae1+hto NgdoE2DQ2uBaeFwNb41d3TvH0WImtg9E7jrae4AGR9TjDUjpC1EtUHBte9O2C6qIOIw1 j3IdVrwt5F8r0+YWEIdbJmDtF5RRQKZ5+ILAmV0/iFY12G4xs64CRd3a9/Q98K09xjiM lgrPd4W1BVr6nYBzqrGBFchySHo399Nd1LvpBVBWDFVgbPEsPukgjlK0iKAaOuMdM+60 k8DA== 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=zF5U5vUhnt7bE83ZTLZTj8GaOaV41Vp3W8l0qtlekwM=; fh=lCwMbqetBpO0Vd7a3gKFArRnLB2AASuTMycQRzK1uok=; b=arMJTebiEEiY/hjvgP0uRXTqeQznc6ddpVkqsAb3xy2cjgft53sT1Jd9kJ5zfhVmPf 4na7HmFNbijf30czvoYowoa5Q1oyI1koiWsOY21cG/GdPu7SsqNmrwHIWJR4g/7CsDqI BlZUdO1kX92J0TxY15TDYspmx46jLkrN3OLIAkhSIeQsiQ8go9BG6QLGw3heoNjP2OFp lOsRhPCq+w/clgPHqRdVuwe3E3z1ZntHRnAtT4iSp4bYcZ8ZrXOjfpB8J8EtuR9fJYkc Y+McBD3yG5em9W8woN/vjFPyRE0t/DFoYu/3OzdOJbrB8rOfs0bTxpSz34UaQIqY1EyH +iEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="1I+/BmVD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id on7-20020a17090b1d0700b002744169a0cbsi9347959pjb.99.2023.09.17.05.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 05:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b="1I+/BmVD"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id A3EDF8028F95; Sun, 17 Sep 2023 01:59:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235133AbjIQI7L (ORCPT + 29 others); Sun, 17 Sep 2023 04:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234810AbjIQI65 (ORCPT ); Sun, 17 Sep 2023 04:58:57 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E828189 for ; Sun, 17 Sep 2023 01:58:51 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-31c8321c48fso2927036f8f.1 for ; Sun, 17 Sep 2023 01:58:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694941129; x=1695545929; 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=zF5U5vUhnt7bE83ZTLZTj8GaOaV41Vp3W8l0qtlekwM=; b=1I+/BmVDu+2dmaZ0bjp81ljNqcXMRYfNXYBPFO011NQLyvGll8OIhPB9k4uTsGzvg1 v0rw+0PXYCTZtXDa2sCC6zSyOuagt9V7qqzaXpBLm602otaKZzRnG4mgHbR5pC8rnOPv G1+bVm6pg2LqAv2NABPPb0iZIxVKT5Zrh9RTseBxNxUfD5vF3h29aHmvKOMjLYgpIqJm c5OGeZbyTPMNaJ3niMBPeM5QQpvE1ZXrxUXYvqAez3RscC/KdprfivoRsLF3nxtwLr6n pnK9/prtuzAUYYjgBYmkQck1cx9nCz4GeqSrotxQEr0wPyVOZuv53ojlfJbBlQGtfdMO IO6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694941129; x=1695545929; 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=zF5U5vUhnt7bE83ZTLZTj8GaOaV41Vp3W8l0qtlekwM=; b=sdBP32EXrVol9d18DvIF52VC61ZobzBTinwQFxDjmEPvbnnwqJrA6DQZjx52rH7LmJ FsMc2zvmvp+BygfOGo/SZLnL9qFzyEd9QKLJe3QkE9K10lnYvjVFrpNjOFRLEDtQ5vDt bIxUwEsMWM37mqf7bT80M44HfwL+bom4kvcbRs5+nrxMrC4cVIuTCvFYiJ8RNEYBK7uB halkqj14BuaDyISQw73Vp1mn6lmnGMEdVg0ZBua7IhCcWHtsA8rM55hWPmt21XYUrYJ3 6LveCMqjeU3IHxgCIXWC4ywQkl7chLhPiJ1uIxboHPADRkkNyeCJyIH89Hdn7iO36pHB N2qA== X-Gm-Message-State: AOJu0YxBTa4oNHbFIaxXohcdEpUBLVbBOyAGDN+M8eN1g/62p4ZFEax4 XKlH+2Oq3hzk2DeXsGZpTCUW4w== X-Received: by 2002:adf:fe8b:0:b0:31f:f710:a943 with SMTP id l11-20020adffe8b000000b0031ff710a943mr3980576wrr.15.1694941129567; Sun, 17 Sep 2023 01:58:49 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4ea0:9945:6800:8739]) by smtp.gmail.com with ESMTPSA id r10-20020adfdc8a000000b0031aeca90e1fsm9240971wrj.70.2023.09.17.01.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 01:58:49 -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 v2 1/2] gpio: sim: fix an invalid __free() usage Date: Sun, 17 Sep 2023 10:58:36 +0200 Message-Id: <20230917085837.6199-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230917085837.6199-1-brgl@bgdev.pl> References: <20230917085837.6199-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 groat.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 (groat.vger.email [0.0.0.0]); Sun, 17 Sep 2023 01:59:46 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777279529104895022 X-GMAIL-MSGID: 1777288260224561873 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..4d74ea3a4269 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) 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) 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 08:58:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 141134 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2037172vqi; Sun, 17 Sep 2023 02:00:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrfdhE893HIW4FNEIW0clrRFsieZ3aPerQ6fkIjQE7uEDFSBIdhfTkp3FqhHr3emKhZThJ X-Received: by 2002:a05:6870:568a:b0:1d0:f5bd:6fe with SMTP id p10-20020a056870568a00b001d0f5bd06femr8544173oao.50.1694941207162; Sun, 17 Sep 2023 02:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694941207; cv=none; d=google.com; s=arc-20160816; b=j2oellGqT75N6oPIJX70iCiedP4SYoBUcnMIsNXgWUbXkMR2RBJdE39nVhPU5HLDpP SozkugvBUrEFNVgGXQnF/3jNxN/HgJLkGzTvvH7U69CLc8L3CTwU7icp3ki6KR1rZsnd 3h5Oxg/1IBvaZ6DoFUvGmsXmQvuMHBhKVTUM4VeBiBzX1ZYeZSeXGrFnbcr4RF6n+UZD zmNb+DgkyvtB8oNy0UBbXr5e7nDy10O52AXKRQEHJHK+74PqHDCMnCCvYWTkNJy73q37 lHFZ0k4GhRfGuiYIITO52Ry4O341UBocUEaHTCx6yQ8uRrAOak4gdJ+n2JJi/ZJOj4hq IfHg== 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=+u66nMfJzlnM3RSBfHLUmO0kR6qeofo6vre+9QbeMy4=; fh=lCwMbqetBpO0Vd7a3gKFArRnLB2AASuTMycQRzK1uok=; b=kaiQsHXZiGatUcCbixLPTle64kF8yeVDd95YKsCUpwod/GiBdh1GiWhbR6lWeE7CvE LILEKcutYloTQOaTsgWyzFpvXmXxMytyUtDhFkKqffJSXkEBz3C6aMoVw9WjLIw7BUZM LQyOgepXk5eohY+VeV9MoThWAh3Qrxotqx5xrHmyGCMq4sSO/v1u68pOUNRKu6/4y6Zo IRXaGhjRqyYPhHMaWRgjhUdjVn599pBGOG7rgtKFChAdxGEc0XOkeu2GzQk9ga+LfVbE 0+Vwa53hrJE64tHNPzFzLzyclBMC8h1KgFoXJlJneQYrWj0IxJB3/pht/yNr40fbEkCi RCGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=MRjN2nZ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id z21-20020a631915000000b0055785a37147si5907893pgl.590.2023.09.17.02.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 02:00:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=MRjN2nZ3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id D18318164695; Sun, 17 Sep 2023 01:59:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235386AbjIQI7N (ORCPT + 29 others); Sun, 17 Sep 2023 04:59:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235044AbjIQI65 (ORCPT ); Sun, 17 Sep 2023 04:58:57 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 829ADAC for ; Sun, 17 Sep 2023 01:58:52 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id 2adb3069b0e04-5031426b626so172477e87.3 for ; Sun, 17 Sep 2023 01:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1694941131; x=1695545931; 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=+u66nMfJzlnM3RSBfHLUmO0kR6qeofo6vre+9QbeMy4=; b=MRjN2nZ3N9kXUEttWugJSgdUnHBKAdImYPpJagwFYEqKZniY/rVg7Ec7AbdQb3oSkP 0rLIfuCIFfYIp0lQheUjqvt1Q2cCfUyvf8wfvW+92cYXied55i9nTBWuoHSf7SCLKpaf vqw0b0a4kS1Bg/unIR/RPTx+SGs7d/Z84kVhS0cvVDk0/wsrBA85u9NVNsM5a9Myehup Y18eNxQEqhkbR3kSMOn2i1E1ptqUTMSMx5bR1sc3qrOF1gJiU0FVY4K4YCVBf1CbOeSw Bvooek9BB+yQ9xwEpb4ywc3y0ODoULA7EaKStSPOKFkg5RTCqwNO3JY3eeufBi2Q1y1G Kmyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694941131; x=1695545931; 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=+u66nMfJzlnM3RSBfHLUmO0kR6qeofo6vre+9QbeMy4=; b=aCdLJrAe5ZQDLi21KWwyEhRFh7IpV09n5cudn+KNdCzk/swpUurtdQzGIMnEjI6Gwr Liw69ntZIaP1btlLEpMf+YrYTjJ8aRoOSuDefyRp9lpn3WwQfKsAxZfxVvYKYMenVVkJ UCBhNj+znKf6hjoYZdaqzqrmdxuyyMkMLBooBYTdPI82cZd1Gh+Bg52ToZivBnh7bYhe Tn0Qlqav2UoCWll+UF+X1zhqOkOax167okdDqXWAXzRu5VVI/+QS2/2ZmitYE9XbA87J b8up7DrUFSU90x0p86VU1LZnzznGs4WSh16wmFABihKKG3Vd9a/79eWH/KkM3GXsDfnS gumg== X-Gm-Message-State: AOJu0YwjSiNuL+rub5ShQAg9FVATtUE9+0WO/kdR3MDYZOEHftCvU/er K6D1j/yfal28IzDiIdg32KyUFA== X-Received: by 2002:ac2:5323:0:b0:503:55c:7999 with SMTP id f3-20020ac25323000000b00503055c7999mr1962964lfh.34.1694941130545; Sun, 17 Sep 2023 01:58:50 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4ea0:9945:6800:8739]) by smtp.gmail.com with ESMTPSA id r10-20020adfdc8a000000b0031aeca90e1fsm9240971wrj.70.2023.09.17.01.58.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 01:58:50 -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 v2 2/2] gpio: sim: initialize a managed pointer when declaring it Date: Sun, 17 Sep 2023 10:58:37 +0200 Message-Id: <20230917085837.6199-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230917085837.6199-1-brgl@bgdev.pl> References: <20230917085837.6199-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Sun, 17 Sep 2023 01:59:48 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777274671455319671 X-GMAIL-MSGID: 1777274671455319671 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 4d74ea3a4269..24c19c7c50a0 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);