From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86640D116F3 for ; Mon, 1 Dec 2025 18:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=y68PE+8MIkJ1RsOV+m+uznVl4WPgZ4iLffSkfESDJys=; b=tEkOg+5aX4g2fwYBa6qBfDIQKx 7yPw9OxQwVEO6iWAxD3zKJmEKhU8HfmZaKnFhLdb7VrlmCOuX92xWqF6L0JPmYn3SnSimdDmKxOnR 01lU6GqDGyaCWyrlTh6mJnpRXpmsAEbnZya/XrkNuaxDHA/N03nz8fwSEubE9QQhP6rfaMEtmQcBE HrO0+KfTxtqQu6aJVIUxuw1JE3W+Pk0hwHYUHw8VSUI5aT7qB3BxwJujenKfngRBJa4UiYjmtNPME hiO+a+NJuPCgfvYxJNSrWmfnhYMMSv2jOOETFRl7k7cjGLT9NNLK9sXpR1r5LmYKOsoWV1rFPakwd D95wr16A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vQ8lK-00000004QiH-3FSR; Mon, 01 Dec 2025 18:36:38 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vQ8lH-00000004Qh4-1MCu for linux-nvme@lists.infradead.org; Mon, 01 Dec 2025 18:36:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1764614194; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=y68PE+8MIkJ1RsOV+m+uznVl4WPgZ4iLffSkfESDJys=; b=fkL6gWkI0HLLZWwrUTz/In7OCCP8PVR5nElK3arvPew674QTQUHRLcZhWxveA7nvoCyFWk 3GEtbOBgEq5u0mR9pW4TJJ4kWbQ9vGgYvDjMBO+HE58RAYJiP6dROmZzjNUQ8UbPTQLJ70 02pcdcQ9Qhs5HNsvItxw0fJ3vbzwPz4= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-167-NAmDLMHrM864mT_0ya8-qw-1; Mon, 01 Dec 2025 13:36:27 -0500 X-MC-Unique: NAmDLMHrM864mT_0ya8-qw-1 X-Mimecast-MFC-AGG-ID: NAmDLMHrM864mT_0ya8-qw_1764614185 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9170B18002D7; Mon, 1 Dec 2025 18:36:24 +0000 (UTC) Received: from localhost (unknown [10.2.16.172]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A47C4195608E; Mon, 1 Dec 2025 18:36:22 +0000 (UTC) Date: Mon, 1 Dec 2025 13:36:21 -0500 From: Stefan Hajnoczi To: Krzysztof Kozlowski Cc: Hannes Reinecke , linux-block@vger.kernel.org, "Martin K. Petersen" , linux-kernel@vger.kernel.org, "James E.J. Bottomley" , Mike Christie , Jens Axboe , linux-nvme@lists.infradead.org, Keith Busch , Sagi Grimberg , linux-scsi@vger.kernel.org, Christoph Hellwig Subject: Re: [PATCH 3/4] block: add IOC_PR_READ_KEYS ioctl Message-ID: <20251201183621.GA919572@fedora> References: <20251126163600.583036-1-stefanha@redhat.com> <20251126163600.583036-4-stefanha@redhat.com> <89bdc184-363c-4d14-bad6-dd4ab65b80d9@kernel.org> <20251201150636.GA866564@fedora> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xpXfsTqxKRlXxqC4" Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251201_103635_486052_AE2886BE X-CRM114-Status: GOOD ( 28.13 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org --xpXfsTqxKRlXxqC4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 01, 2025 at 05:26:27PM +0100, Krzysztof Kozlowski wrote: > On 01/12/2025 16:06, Stefan Hajnoczi wrote: > > On Sat, Nov 29, 2025 at 03:32:35PM +0100, Krzysztof Kozlowski wrote: > >> On 27/11/2025 08:07, Hannes Reinecke wrote: > >>> > >>>> + size_t keys_info_len =3D struct_size(keys_info, keys, inout.num_ke= ys); > >>>> + > >>>> + keys_info =3D kzalloc(keys_info_len, GFP_KERNEL); > >>>> + if (!keys_info) > >>>> + return -ENOMEM; > >>>> + > >>>> + keys_info->num_keys =3D inout.num_keys; > >>>> + > >>>> + ret =3D ops->pr_read_keys(bdev, keys_info); > >>>> + if (ret) > >>>> + return ret; > >>>> + > >>>> + /* Copy out individual keys */ > >>>> + u64 __user *keys_ptr =3D u64_to_user_ptr(inout.keys_ptr); > >>>> + u32 num_copy_keys =3D min(inout.num_keys, keys_info->num_keys); > >>>> + size_t keys_copy_len =3D num_copy_keys * sizeof(keys_info->keys[0]= ); > >>> > >>> We just had the discussion about variable declarations on the ksummit= =20 > >>> lists; I really would prefer to have all declarations at the start of= =20 > >>> the scope (read: at the start of the function here). > >> > >> Then also cleanup.h should not be used here. > >=20 > > Hi Krzysztof, > > The documentation in cleanup.h says: > >=20 > > * Given that the "__free(...) =3D NULL" pattern for variables defined = at > > * the top of the function poses this potential interdependency problem > > * the recommendation is to always define and assign variables in one > > ^^^^^^^^^^^^^^ > > * statement and not group variable definitions at the top of the > > * function when __free() is used. > >=20 > > This is a recommendation, not mandatory. It is also describing a > > scenario that does not apply here. >=20 > If you have actual argument, so allocation in some if branch, the of cour= se. I'm pointing out that the documentation uses the word "recommendation", which is usually not considered mandatory but a suggestion. Please update the documentation to clarify that __free() _must_ be assigned the real value (no NULL initialization) so that it's clear this is not a suggestion but mandatory. Stefan --xpXfsTqxKRlXxqC4 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEhpWov9P5fNqsNXdanKSrs4Grc8gFAmkt4CUACgkQnKSrs4Gr c8jLDwf/eWxDE5uirmFhIp1judTLNN8oBJ2XAI8bBsjv2vTN64KlNTUqvQt4fsNu 5DwI6lkNvDuez34Wkg5kLTvQMPUhMJnPHb1s4KD2UvgbBq+dp1jmJ8VfzoglSkyk k2CT1CgvgoJmUnhngtldfKqHiu5j6e/2Dx8xyqLF5GUq+OrAn+xog+P3tIRvi5yn BuijC0Wd48jO1W0o3xNS9tPVJSchLWTuaO5LCIsKYq6NMGkUQmUpBx64tMCWwVuD NYOTP3vEaJxEUlg2Shqx2xNjPLgQX/Yi6uzdDeT/+WwFoT9E8OUD1nlJvLiUKWJ4 2/Udb13YeFPSBBxBkeaESVyPZbcFOQ== =QIpw -----END PGP SIGNATURE----- --xpXfsTqxKRlXxqC4--