Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1574035rdb; Wed, 20 Sep 2023 13:04:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrc5/8m2Nc5pbEoCo/BtV46sSaTKUW3Hf83zjLT3TwS3npepLsS+Yr9M6//laS81NpX+Tf X-Received: by 2002:a05:6e02:1d83:b0:349:3020:d103 with SMTP id h3-20020a056e021d8300b003493020d103mr4472369ila.25.1695240246359; Wed, 20 Sep 2023 13:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695240246; cv=none; d=google.com; s=arc-20160816; b=Z62R394qSRZquz0+5FGCWYF9c5QfbP64M7AsOAwiTBtU6xGw10LcU65F3YkX74bfKz JNPNoMWLJaSx7ZhUnM7srC7X+OBMI8CMObK/Uba6kz24VMzTavNliLEnJJ6TJeObh6Mi Pba9lqV625CbucjKIWuwSNyDWomRJ+qTveg6sLR/8FIr4J4zn5mCFWx3m11i3PH/FDn1 0bKiUDmDwnQkbWU7ZK9aixwk4MmlhtW3bbi9rzrjTEiy4xY3w+ojuBg9NONIf/ii8dpN nkPuIETs/tF9TvoAeSNxE7yxUjOjgXTtSS7/pFDrFmAgPk2x9j1yT08rxEtTLcqTXlua W69Q== 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 :dkim-filter; bh=VxODT37PlX5ZCRr1cOltUaqq8vMZMOJABM5YiBToizA=; fh=pko5DNIeGkkuspgJgRMHZtuWlAP4BeQGl9usWQj0lR8=; b=QuVamaRfrEJJ51a4ex1y+D7dgW4TlUNaPHpyFSEEpc6HaXV36yrS/WvbbaXDyVJGVJ SbglEXUsS+JyLKTAawaeX/e8l4T+9vSc+RL/9mRR9lEqzpNJg6Se2UPMp17jov+pqsJy SrMt3m3ZsCzD4DHfRQZIbAcMEqmP9sdywx2Cewmim7ydym6vk4IMSgk62Yd2rv3aPeAT gM5l05UjprSwgcU3fyv5AJNaAmGW+00efaEIxVAxLHqUNrAzlGAB8vNuRnSYz0Q0dcvY ZybuYLCzIW0GiaIIPn3LNmERWpy80AefExLsvNubCkLfdPmv8fX/OtoOhocsQUGDWLMO vBbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=l96cjY6m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id dw9-20020a056a00368900b0068c0323c2b7si12350093pfb.172.2023.09.20.13.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 13:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=l96cjY6m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 9037A80A9991; Wed, 20 Sep 2023 11:56:48 -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 S229691AbjITS4r (ORCPT + 99 others); Wed, 20 Sep 2023 14:56:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229461AbjITS4p (ORCPT ); Wed, 20 Sep 2023 14:56:45 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 348B5C6; Wed, 20 Sep 2023 11:56:39 -0700 (PDT) Received: from localhost (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id 32A5E40F1DFB; Wed, 20 Sep 2023 18:56:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 32A5E40F1DFB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1695236197; bh=VxODT37PlX5ZCRr1cOltUaqq8vMZMOJABM5YiBToizA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l96cjY6mmOxPcAT2xjV6US2bAUmNaGaKqnJAGlHa+7rUq0vr/XFtQn3z0QIXgmrr6 G/oov4nIlX9KNDqA+a8TsFLJI9SOFXlIdKbVWOW4YULfHOSIFLmX4ZrVdp2tIld8yY aKeH6ajB6607YSusjSUXIaaY7H6A2d2dEqiYF4ts= Date: Wed, 20 Sep 2023 21:56:36 +0300 From: Fedor Pchelkin To: Mike Snitzer Cc: Hannes Reinecke , Alasdair Kergon , dm-devel@redhat.com, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org, stable@vger.kernel.org Subject: Re: dm-zoned: free dmz->ddev array in dmz_put_zoned_device Message-ID: References: <20230920105119.21276-1-pchelkin@ispras.ru> 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]); Wed, 20 Sep 2023 11:56:49 -0700 (PDT) On 23/09/20 01:54PM, Mike Snitzer wrote: > On Wed, Sep 20 2023 at 10:35P -0400, > Fedor Pchelkin wrote: > > > On 23/09/20 04:06PM, Hannes Reinecke wrote: > > > 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? > > > > dm_target is required inside dmz_put_zoned_device() for dm_put_device() > > calls. I can't see a way for referencing it via dmz_target. Do you mean > > passing additional second argument like > > dmz_put_zoned_device(struct dmz_target *dmz, struct dm_target *ti) ? > > No, what you did is fine. Not sure what Hannes is saying given only > passing dm_target has symmetry with dm_get_zoned_device (and > dmz_fixup_devices). > > > BTW, I also think it can be renamed to dmz_put_zoned_devices(). > > I've renamed like you suggested and added a newline to > dmz_put_zoned_devices() and staged this fix in linux-next for > upstream inclusion before 6.6 final releases. > Okay, thanks. > Mike