From patchwork Wed Mar 15 11:31:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 13175675 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53B15C7618B for ; Wed, 15 Mar 2023 11:31:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6813C6B0081; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 631246B0082; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AADB6B0083; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 398296B0081 for ; Wed, 15 Mar 2023 07:31:50 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 075D7A0A02 for ; Wed, 15 Mar 2023 11:31:49 +0000 (UTC) X-FDA: 80570917980.09.0AFD3FD Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf12.hostedemail.com (Postfix) with ESMTP id DB82A40019 for ; Wed, 15 Mar 2023 11:31:47 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=F056L0ij; spf=none (imf12.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.65) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678879908; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9V8eylqcIM14HkIIx9TRWvpBvzEt953XO6IZPlCr1Vc=; b=w/vRpm31xniiE8weelZIOZ11lQa2vYddpZMD+DuhmYcGJ1Mfncrp+CyaJCmc3QNGX1TDCO qArYwNgKYJrqIc8txdrIjVslsRwsZ3FpkUUhWOpFtHSEADGBiVb7mQWtfw68hcyWQQkfP7 XGNvTX/DFVpKOIsWxiUcBFsznD2q+N4= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=F056L0ij; spf=none (imf12.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 134.134.136.65) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678879908; a=rsa-sha256; cv=none; b=MXiOElyWH3GS07bq2QvaV0+ek92GGtIDWRJi6bMUU1Sc4D3DlL/Qc0NjAuHJHMeRoWqX+S qe9swvkhhB///tu56UagMJVUV+/qV/X3ZN9Kweqs1Bs6sKS1d8jTYtMlPWx4XaOWe9c1SI /GLl0XlA5eSxN2OxNc2l4ywpGkjV9+U= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678879907; x=1710415907; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UWzGGkVyoi9uLhDhUj8Gm1X5MYwKK4ubOq9Kr6YKifI=; b=F056L0ijJGnIAQFCTeDVpNKHFVV7Wmrc4M4i/AtcejXvMqql47RZAclC 8i+nZ/rzwgR0xcRmr9zu4v+Vq+kGVgeZ7JBpokbKu3IM8SN1XFf8fNcjY Kd0xhBQsupCfPJ0rKrIOsUbFm4Bf+gOdYPFHo7V2jMhU5XIf/a9b/VVha HOXdCczs30jS9NciTJUAUmhcUCcPTJnBGnhBhVuTT6rFxX5FvcFA9IHDD HDawVjzDAQ4HnHoLuF9YB54GBoZqmNPumnMLhyQZ/woq/2jkqpArODuz0 3IbTp7zlavWW0wD9c12fCyeMxVSxLCTD5KLMihzw1jt3RD9zKo0sHHP3Y w==; X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="340040121" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="340040121" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 04:31:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10649"; a="768456010" X-IronPort-AV: E=Sophos;i="5.98,262,1673942400"; d="scan'208";a="768456010" Received: from nopopovi-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.33.48]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 04:31:42 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id CAC6910CCA1; Wed, 15 Mar 2023 14:31:35 +0300 (+03) From: "Kirill A. Shutemov" To: Andrew Morton , Mel Gorman , Vlastimil Babka , David Hildenbrand Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Frank Haverkamp Subject: [PATCH 05/10] genwqe: Fix MAX_ORDER usage Date: Wed, 15 Mar 2023 14:31:28 +0300 Message-Id: <20230315113133.11326-6-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230315113133.11326-1-kirill.shutemov@linux.intel.com> References: <20230315113133.11326-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: zpr69qzpt9pmh8qke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JeuY8a0VL/3Tb56y3d6S9L1Tb+W5ydPXNn/aMYm2+WHoau1mR5j3DOCKMKfO/DzwviFv0ow0ukT8ClkCvOBDdQRT5N2zfD0ZNC5+88fpOBct7y3QDfRvaFJm3YLjtgj75SgeeyW+pUFvE32gnMJJ76Z6XAxGRWEKCbo7hzE7l4FlW1cxOY3g8LKo X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: MAX_ORDER is not inclusive: the maximum allocation order buddy allocator can deliver is MAX_ORDER-1. Fix MAX_ORDER usage in genwqe driver. Signed-off-by: Kirill A. Shutemov Cc: Frank Haverkamp Acked-by: Vlastimil Babka --- drivers/misc/genwqe/card_dev.c | 2 +- drivers/misc/genwqe/card_utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/genwqe/card_dev.c b/drivers/misc/genwqe/card_dev.c index 55fc5b80e649..d0e27438a73c 100644 --- a/drivers/misc/genwqe/card_dev.c +++ b/drivers/misc/genwqe/card_dev.c @@ -443,7 +443,7 @@ static int genwqe_mmap(struct file *filp, struct vm_area_struct *vma) if (vsize == 0) return -EINVAL; - if (get_order(vsize) > MAX_ORDER) + if (get_order(vsize) >= MAX_ORDER) return -ENOMEM; dma_map = kzalloc(sizeof(struct dma_mapping), GFP_KERNEL); diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c index f778e11237a6..ac29698d085a 100644 --- a/drivers/misc/genwqe/card_utils.c +++ b/drivers/misc/genwqe/card_utils.c @@ -308,7 +308,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, sgl->write = write; sgl->sgl_size = genwqe_sgl_size(sgl->nr_pages); - if (get_order(sgl->sgl_size) > MAX_ORDER) { + if (get_order(sgl->sgl_size) >= MAX_ORDER) { dev_err(&pci_dev->dev, "[%s] err: too much memory requested!\n", __func__); return ret;