Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1183388lqj; Mon, 3 Jun 2024 12:47:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWrFtqCjuVGPEvQ7U9VciJD/rFxJLfCwPxAsFLog4fFAeH/xhL61DnPFvIdsc1L4drmkoTXpsO4CgTgIbzz3nEnoH/z8SoKTqTVpopqiw== X-Google-Smtp-Source: AGHT+IHMO5flSXq3XQQnbs0EC0k56SJWGmJz7J6+KiODc3la35O+FU+ZZMfsNioCxMLP3u7wnSYO X-Received: by 2002:a05:620a:1a19:b0:794:ece7:926f with SMTP id af79cd13be357-794f5c5e942mr1283179185a.10.1717444048083; Mon, 03 Jun 2024 12:47:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717444048; cv=pass; d=google.com; s=arc-20160816; b=Syuv8m3630zL92+qJwf0wwPZ+Qp9Uk/Iqas7P1dnMTswJvbZ9WAkFX/rsLSi1czUCK gSp2qVnkwUxpmDeE7iMQVsHSmsJiG7ScVHCyB3lOIjH0lVfgW+eV87VHiViU7SX6gIGk A/YnUjwxc2BfjTftcCacuIVhM+sgdDQIJwhPbHpH8SkVo7z5mHGud0jP70hcv54GBs9U gh1FS7io0fzo06aULijFPBLqgrzwBQp6+ONaZHTtPaLqt9lY9p1UEdzHMEruEBfHeZYo YQ657d0puUKpgE00cYDNoTQcwilxcjLnEOor7SPQStkCY3Wdi+QRQul21SgUJuvIlz2w EdlA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qRIgTbknjOeiMSBJrXV4A7uI7IcMofKxL34DZ8iKNvA=; fh=u2kYSFgO5xn4Oc5Jlk7MciyQo33+DD3PHkLz01ptV7Q=; b=VV2cza9RU2VyzLk9QnfoM30goGA7zOFqPrAI6gybsWt8YMdySstx+5fHTI/9wqaEuX j+JXlQox3e0P/fusMAFViJJwYjylyqDbAFWpmpAY97vp9cRcOksu26hieszGt9GiT8vy OISAPB0iofcHcO3PcIXP2Cf5rWnyppm7dIGVIJwi11T8eFNHxEscLCJ684sTlFsMxnEP DuqaaHO3pgBwKiZPJ+UABe+XdYhKiyeWwWXTrwrTpMJqznLs/6+NZG1G+ez3ilN6et9e axB5bmJILnF1BWya1Nc32PGhV4d39JXFKqTQr+nXqZ/f/3TMVvNcxy3ftpWT45Ox5Lmi HXag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QPmyw51K; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199656-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199656-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f2f15507si68257885a.158.2024.06.03.12.47.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 12:47:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199656-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=QPmyw51K; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-199656-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199656-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CC0911C23098 for ; Mon, 3 Jun 2024 19:47:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F21E13A865; Mon, 3 Jun 2024 19:47:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QPmyw51K" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37C1620ED; Mon, 3 Jun 2024 19:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717444040; cv=none; b=AkL8mfQGad28RddTdqpCal5kHA7hkfz0IoZZbr2DK4LKa1ZtdNSWQoBUExJxSh95ea/Y3O1f/bLNxKBJRW5TrRS/SOTzjZOOUDmXa9uFtTsttJp57cFM8aJ/S+n1Vwj5wetRpYzC/qpnBjIXuAIXscHDAaSWWXqm+sywWUGALig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717444040; c=relaxed/simple; bh=v+0RbsfKdGgk/6XvGRknMDTc2wiUcVUl6dcouRw8NJ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PsZz++ekOgyEsZFwTkJi7ONr/YQ0PYJEeUSb70SPUgiZoTo4s5Vs3o7ZjLqW/iCCJGrZ5RY5VUkr3Vf/ekSq4VuWE1o6gpO2wUHaX20/JjlRhs1PJEu4qrfonZ0CVpFKHvzheTfEvXjsrm0GvCSVm8b/XVSl859VBjJFxumVMWI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QPmyw51K; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F955C2BD10; Mon, 3 Jun 2024 19:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717444039; bh=v+0RbsfKdGgk/6XvGRknMDTc2wiUcVUl6dcouRw8NJ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QPmyw51KfG4g3+7Ei/p0tAOrX7io955hQRR8FthZq/gWvI/n9Z4SxaNt68zwa9g2O 6POAii0RDLzdMk6TOEGtP6JwF5VGbu8HblqBBvmbEsCBnq5G9jnhtcvfR9FbQt5J9y ZzilGkhi05j99m90Sc7r6s825ay12VRbAlQT0PBMtVssCYPiCXhQcNhfeAJ1Z0h73D Jj1MTDr0pITf2p+a8k0YPApfPUETkikOq2zpjH++zD/cm2JJxJiRZaQa2+Uuv2tzks wmQnrmI67Ev7VkJhZmKyW1y6pLrq45fYlTzCEDAdFHPdvpqzkjt+Vi3tvASCycWAPE GrirwzVbQAuKQ== Date: Mon, 3 Jun 2024 13:47:17 -0600 From: Keith Busch To: Andreas Hindborg Cc: Jens Axboe , Andreas Hindborg , Bart Van Assche , John Garry , Damien Le Moal , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] null_blk: fix validation of block size Message-ID: References: <20240603192645.977968-1-nmi@metaspace.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240603192645.977968-1-nmi@metaspace.dk> On Mon, Jun 03, 2024 at 09:26:45PM +0200, Andreas Hindborg wrote: > - dev->blocksize = round_down(dev->blocksize, 512); > - dev->blocksize = clamp_t(unsigned int, dev->blocksize, 512, 4096); > + if (blk_validate_block_size(dev->blocksize) != 0) { > + return -EINVAL; > + } No need for the { } brackets for a one-line if. It also looks like a good idea if this check was just done in blk_validate_limits() so that each driver doesn't have to do their own checks. That block function is kind of recent though. Your patch here looks fine if you want stable back-ports, but I haven't heard any complaints till recently :)