Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1514543rdb; Wed, 20 Sep 2023 11:10:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtnzVDr8mUsQI1g+Cjxqzxfmhg1wfpguIQY/VaAFNQxHhX7s2QyahS8ZcAMYDmOM1KbVMT X-Received: by 2002:a05:6a00:17a8:b0:690:ca4e:661e with SMTP id s40-20020a056a0017a800b00690ca4e661emr3863201pfg.19.1695233401347; Wed, 20 Sep 2023 11:10:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695233401; cv=none; d=google.com; s=arc-20160816; b=oF6cGxKhO+dEl/aGn+s3Wa61EFBnaOViKSLN7czEo/xaMT9lbCSpOPY74QQoSFhdD/ CqVNLcF5EglEKuReAjl7bFEdV1rH18/t6l5S4QghC/qfxw9iEkMZiTuzFs5t/Wo3YUe/ csxguajDQ5qqeTJItF+GLvgaxXA0H/zBQmjieG9OLmdlCBXsRRau0afT7XJr/4VNrqE9 VS4qC7R6zkIWqlQhkX0gdaKEweUpCthkxEMbknyqPl91PAz4BAk77IGrSrzF6JIw+XV1 dITMnNi37p2r1njMkj89vqsx0FvpMXiS3yBZmxS/otdJhcJBqyl9mhSVP4DEbN/dUwK4 7/Vw== 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; bh=sMUjbe6jAZJm7ZNBEI2GzRHbQh/3nvCFD3HmyB44o2Y=; fh=ey1gMA4h3SGpWgbWBEbE5riY/W9Lf3f5aNfQycEhmUU=; b=NNYcQo1juTlkjKh7xwyGvZULMbgOxIRbNhRxJ/0AzMQO15fg7w/fl3qAf2q5p8/5U6 lREXxzBT5ca77B9cq4ynrpgGKIV6HBt8YIw94TAvQ+0AFyCA9eTyfXt+ES6mEG+I9swv XXtEYTbc0SVgWsKav0CO8eXTgUL5LcuILXcnW54SXwPqJk9H3cWi8ThRmsSGrKJVoBR4 2/5dGWQwBRdu7ze8WJlHYTQEZtABtgGoe97Lk9Fe7End6y2hsP2bShz2pdfLR/4OIj1X dB1FfiuMOF7UzX6F8mbfIPqn7TkvPQvGh4+QTl/fU7lcWd8zgw9hFf9u3FNinHkltJNk 4BWw== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id v3-20020a655c43000000b00578a7f5a0adsi4137031pgr.149.2023.09.20.11.10.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 11:10:01 -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; 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=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DF93C8332367; Wed, 20 Sep 2023 10:54:59 -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 S229583AbjITRyz (ORCPT + 99 others); Wed, 20 Sep 2023 13:54:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjITRyy (ORCPT ); Wed, 20 Sep 2023 13:54:54 -0400 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0723A3 for ; Wed, 20 Sep 2023 10:54:08 -0700 (PDT) Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-773ac11de71so1060285a.2 for ; Wed, 20 Sep 2023 10:54:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695232448; x=1695837248; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=sMUjbe6jAZJm7ZNBEI2GzRHbQh/3nvCFD3HmyB44o2Y=; b=hlvSnpF4u88GmTjJ8lm/jLC96GYu14FicJMjfuTX2muFscIFIPrDx5z2TyKp57N423 AkcgUec2+FLbCraex8R3uL+5kRWcdZC7v2bf0NCrsZpigU/VbSdi+TJE4vqN4/jNXmqx vGLSzpBikmWwwhgEwVqDcgQ0f1ssak4+CJPoYRWQlh/idOep8nlnkl5DMo9kMi+SyUsc FaB4waQDjqzHvGJyB9fxY9mjpKWnuY9qutzXJotTwVn/uX33wNkx824He/yiMUUTO9o6 fU8oc8TnDy1lfLpOiJ5Nvv11wLQvIdcu6Iw2tArds1rq1zg1gHkt34l2ZZpZtkTz7Qlg 64gQ== X-Gm-Message-State: AOJu0Yww7fhkl5C4zr/rzU4tgxYx8YK8HJkSPIsittDpdEVNeFPHWrV1 DTMTvkJCn49krs18oTtbTJl/2VFsTKApHOiHww== X-Received: by 2002:a05:620a:3890:b0:76f:19fd:5058 with SMTP id qp16-20020a05620a389000b0076f19fd5058mr2422766qkn.78.1695232447730; Wed, 20 Sep 2023 10:54:07 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id d21-20020a05620a159500b007710052789dsm4986047qkk.94.2023.09.20.10.54.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 10:54:07 -0700 (PDT) Date: Wed, 20 Sep 2023 13:54:05 -0400 From: Mike Snitzer To: Fedor Pchelkin 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=-1.0 required=5.0 tests=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 10:55:00 -0700 (PDT) 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. Mike