Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1632599rdb; Wed, 20 Sep 2023 15:08:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH5MaDlXKE2Awy+7Y6wFCDVlHszkHg6ten9iSkhboJsG17UH0IxlPV398DNPzgSjGy1Ms5k X-Received: by 2002:a05:6a00:2da1:b0:68e:2478:d6c9 with SMTP id fb33-20020a056a002da100b0068e2478d6c9mr4469840pfb.2.1695247701559; Wed, 20 Sep 2023 15:08:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695247701; cv=none; d=google.com; s=arc-20160816; b=RJw4hCGNGIMjPFsmCsggTP//q170Q8sfOzUgVjHywRHiThcpV52q10pK9Mch2uyxH5 2/nlilROk6wwL6sDd0Wheb1ghC3zrVYiyKOH4flfYfdEkj8F3tjs6CRsvb1osCi2MPUI nCk/fZU+YJM3Kr1tgPWP5HcQFNtucX/W+7CD2+qEkUefhu2ZtiyOBzEDL0wDyL2RHquS mqJAFWwdqABKRYGguFez6gENwwWWhXhmrCMEfrctM+ZzSX37XSi4OZ8gVi52RPawUIdA fl8WHFu745JDKJ3LJImTX2iP855vmKwQ8W970EdkXP9ACDCku9kMVq6oDXOzZTkIXaRf aVew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=lT96gdfoI65aK8m45KskVCHA9ZIx8TVMnfjnNxtCDHs=; fh=/K3TQhE/MINvpkcDDn1dsk7sDIAMGwLl5sC6zgXivPs=; b=uG8KWFEdvLq7SIYMffnOSt6bBWmcy1fiEUY7E85nXEJIJWFNmWF57Mu2cx45oLjiQX nbe6d6/n2Ub/V1Eag6e9OWuPN/i94SxGUQ1iLBfIaiOQb3pfCg3LRkgG01w+65zRsQQW 1AstHSDdYpf2fNyYuBsMSqm94WNLAZ/eCrMihMWnNkt04oIPywJjJuRfvPYJrIJhSfRa FHICzMFlQos0jsJ7LdjtBGOtKNTco3t06FwN1iw0BeOL1oosJdoSI3m/ToWScPg8YjgD T2BAAnLCwS0BsfGVCjeMStBWuR5HitL8A2h5xaGjTe1ULYXuRYCNCFZc0kt4RcV7aKH0 E48w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=agXzR6wQ; dkim=neutral (no key) header.i=@suse.de; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id e10-20020a056a001a8a00b00690bc2ac50asi81091pfv.246.2023.09.20.15.08.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 15:08:21 -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=@suse.de header.s=susede2_rsa header.b=agXzR6wQ; dkim=neutral (no key) header.i=@suse.de; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DB578802940F; Wed, 20 Sep 2023 07:07:09 -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 S235125AbjITOHJ (ORCPT + 99 others); Wed, 20 Sep 2023 10:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235041AbjITOHI (ORCPT ); Wed, 20 Sep 2023 10:07:08 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52062D8; Wed, 20 Sep 2023 07:07:01 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CFBC621AFC; Wed, 20 Sep 2023 14:06:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695218819; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lT96gdfoI65aK8m45KskVCHA9ZIx8TVMnfjnNxtCDHs=; b=agXzR6wQ1ZAXY4KmanWVya+HCJxw+QBKGWEpk9irinuDPjlNo3TbNU+BsR0ih4f+hulH5O fZHxc9V5CiHjaWcTxpVQf8gKnue/KmBuqYyhY9mmzJhIxSE376ECSFycK5ktpwm+9O70ec BgB0CQsJc3u18fvTBwRiRRdunWhplT0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695218819; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lT96gdfoI65aK8m45KskVCHA9ZIx8TVMnfjnNxtCDHs=; b=hzbp62C3D2e3S+Fb89T99kUAYSIbcEotcDm0f7YEMs6duf6l1mFHJo7YvAKfzGHStcZU9X qtBdCHe8pOkeaRCQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 19CC61333E; Wed, 20 Sep 2023 14:06:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id +tDyKoL8CmXfFgAAMHmgww (envelope-from ); Wed, 20 Sep 2023 14:06:58 +0000 Message-ID: Date: Wed, 20 Sep 2023 16:06:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] dm-zoned: free dmz->ddev array in dmz_put_zoned_device Content-Language: en-US To: Fedor Pchelkin , Mike Snitzer Cc: Alasdair Kergon , dm-devel@redhat.com, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, stable@vger.kernel.org References: <20230920105119.21276-1-pchelkin@ispras.ru> From: Hannes Reinecke In-Reply-To: <20230920105119.21276-1-pchelkin@ispras.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 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]); Wed, 20 Sep 2023 07:07:10 -0700 (PDT) On 9/20/23 12:51, Fedor Pchelkin wrote: > Commit 4dba12881f88 ("dm zoned: support arbitrary number of devices") > made the pointers to additional zoned devices to be stored in a > dynamically allocated dmz->ddev array. However, this array is not freed. > > Free it when cleaning up zoned device information inside > dmz_put_zoned_device(). Assigning NULL to dmz->ddev elements doesn't make > sense there as they are not supposed to be reused later and the whole dmz > target structure is being cleaned anyway. > > Found by Linux Verification Center (linuxtesting.org). > > Fixes: 4dba12881f88 ("dm zoned: support arbitrary number of devices") > Cc: stable@vger.kernel.org > Signed-off-by: Fedor Pchelkin > --- > drivers/md/dm-zoned-target.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c > index ad8e670a2f9b..e25cd9db6275 100644 > --- a/drivers/md/dm-zoned-target.c > +++ b/drivers/md/dm-zoned-target.c > @@ -753,12 +753,10 @@ static void dmz_put_zoned_device(struct dm_target *ti) > struct dmz_target *dmz = ti->private; > int i; > > - for (i = 0; i < dmz->nr_ddevs; i++) { > - if (dmz->ddev[i]) { > + for (i = 0; i < dmz->nr_ddevs; i++) > + if (dmz->ddev[i]) > dm_put_device(ti, dmz->ddev[i]); > - dmz->ddev[i] = NULL; > - } > - } > + kfree(dmz->ddev); > } > > static int dmz_fixup_devices(struct dm_target *ti) Hmm. I'm not that happy with it; dmz_put_zoned_device() is using dm_target as an argument, whereas all of the functions surrounding the call sites is using the dmz_target directly. Mind to modify the function to use 'struct dmz_target' as an argument? Cheers, Hannes -- Dr. Hannes Reinecke Kernel Storage Architect hare@suse.de +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald, Martje Boudien Moerman