From patchwork Thu Sep 28 05:17:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 13401961 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 35D49CE7AF9 for ; Thu, 28 Sep 2023 05:17:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A6AFF8D00A4; Thu, 28 Sep 2023 01:17:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1B218D0002; Thu, 28 Sep 2023 01:17:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E2AD8D00A4; Thu, 28 Sep 2023 01:17:44 -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 7AE948D0002 for ; Thu, 28 Sep 2023 01:17:44 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 24396404D9 for ; Thu, 28 Sep 2023 05:17:44 +0000 (UTC) X-FDA: 81284848848.08.8D86FCE Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by imf15.hostedemail.com (Postfix) with ESMTP id 4EE7DA003B for ; Thu, 28 Sep 2023 05:17:42 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=u5C9NHY9; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf15.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.221.47 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695878262; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=yIJ02qSOp4xVGoLXSfG6FeVc5mYTe6HFTw5ng2uAEW4=; b=M/lfUH/LL+fA3xWSTWXrVTQRNKsiSHzTrZA/PtX6xZBfYhYFWrOkpQAbDLlS+pMj3Jxrek YgJgubt8eUxf6osU/O6Uwj6JcPrIrHRaZzBPysdN5hP3O607+2NcwAy5h8ybuWcfozbp8x LWFlYzrzXHI2teylrZ3GZvCMv1iXhig= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=u5C9NHY9; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf15.hostedemail.com: domain of dan.carpenter@linaro.org designates 209.85.221.47 as permitted sender) smtp.mailfrom=dan.carpenter@linaro.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695878262; a=rsa-sha256; cv=none; b=nbMVU0Vgb7u1ab05iN8qZwrtMAzaihHw8+771p6PxXMFe9fProQi0HKl64Ocn9ma3wvFf3 C7lfb8haxI0bj9w8zlViGH3U5kTUTX4rbG14pyW0DfGERx1e3wjbbG7fXbhZLA+W2n2AK5 96g4RSdyj5DNe5gkesuWoC+reOBU9nw= Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-3248ac76acbso22348f8f.1 for ; Wed, 27 Sep 2023 22:17:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695878261; x=1696483061; darn=kvack.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=yIJ02qSOp4xVGoLXSfG6FeVc5mYTe6HFTw5ng2uAEW4=; b=u5C9NHY9/EqwUzUxb13dMJDv6KEwKv9Lk7B5HqNUUDotALTxge0jCunNIw8WD1fX6B XAJOk5LEuty8Dx8wnu9F+zzVCO9pMWsrTcy5NBvHvL48EEXTgW0FS73+E/4UyJ20LPmr ZYSvPJ9TXkNgZh2CMLP8H9dnIf3eb6kmNzYZLqcFNRYwd0b/H5pEuhTlN6wgAVQXmxk8 Wx0r8FL80DkfdLGmJt9rnyJ2oDDrspa7tL6cdSkkvti0YcHsWNYE7X69QAHd9/e7oSca x9oUYYX8VmOJWt26/jsxUM9ZkVQmHme9SiRPulhvS1pKpRruYdZhawz+fN+Xrvd8zYIv YR7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695878261; x=1696483061; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yIJ02qSOp4xVGoLXSfG6FeVc5mYTe6HFTw5ng2uAEW4=; b=RoJAoeot0l+LWy3IfIXJX9b8SnKo4C0PdpUMQUYhAXyhm65zlEADYD5qRPvS4tdsgn YqTQROqsauYJY530RTXgQ3Yj6VFzetLP86riOM/Mibcw3+Y+bLTlTKWpDYjKbWwNGCuM +fupsdJOZ/aJTnKyf3ppVDxpNfjI3i9kfXBLpHOTv8VJj4kX1LV3RoAP5fP2Zzl+w2GA dv930T7tuU9iXATEMl3lacvGTrp7dB8rbidLkEhBOPHi5RlU+ks3AqFeGBrilbUcRS6x UjbosEtgbvdcvqbpFaqcprCQjN3EeIBwFvjs53MlVevTpPUTyGYkx9ynSMDf2d2wRoHg qUSA== X-Gm-Message-State: AOJu0YyL8webRxPldQeNKNizpGvkfll2XzqysF29LIQ4/GkbNJO3c6WT t6o2G/8BkvU42Ok14Ta6LzxmJw== X-Google-Smtp-Source: AGHT+IGW1VktBGa6+a5T5jdmOd3Atafh7P5YxQirMnTaHLGkZodlJVLzcEa/horPK5LxM8anOVAyIw== X-Received: by 2002:adf:e58f:0:b0:317:e68f:e1b2 with SMTP id l15-20020adfe58f000000b00317e68fe1b2mr183865wrm.28.1695878260718; Wed, 27 Sep 2023 22:17:40 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id 11-20020a056000156b00b0032485046055sm544180wrz.5.2023.09.27.22.17.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 22:17:40 -0700 (PDT) Date: Thu, 28 Sep 2023 08:17:36 +0300 From: Dan Carpenter To: Sidhartha Kumar Cc: Mike Kravetz , Muchun Song , Andrew Morton , linux-mm@kvack.org, kernel-janitors@vger.kernel.org Subject: [PATCH] hugetlbfs: fix an NULL vs IS_ERR() bug Message-ID: <1772c296-1417-486f-8eef-171af2192681@moroto.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Rspam-User: X-Stat-Signature: u5amy8u9zby339ewkqqs3ti6qcxc9gku X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 4EE7DA003B X-HE-Tag: 1695878262-293746 X-HE-Meta: U2FsdGVkX188HJaDoq75q/TezZwxCVwIjQqDk7y1OvCehBSJGTjcKqaWzjVqPMSE/hK/ZJbEgJ7JpIib5AUSi/jkZAAcakXhI1ooTPVRKOaknbqfC+am+PwRUrT95AeGjBTselsXnhikJyHZWTBBsPDAcpUUe+DGB5GFnUVyidJvbp47Uelu5lpjeiRs6Nk3UEbwxDqIiPWSM+1cB/a678W3RGRxKREQ9+j4bO/9HQCgbPhO7+e3P+cDbvDcZUZlMbCMszeBHLEj120UEOy/4J+r6I/r9qXKRsKKuhOQLR9iJN677Cy+jnpX1sZ40SZB/2+WUk1eYLWzzbfB9vPfJcy972aDfdR11YFOYkRkoheqe0F75aPPd7AyAvA3E5gDZqxnBqsQKnfJYXis5S6ussEcPRoov93wMzuIGsZWW/iJpg05HSXLqFMbprP9V0GQLMz+SSnzNn6RJYxFonscZUfNR7KDMsa6O9xJLFzAL02DU/czkNpByQ2cyrU4RTkxs/6bFZv1v7MoBExOo77vkbQRnlsqpb3Nwsz0jE/hiAXjGqF6HkQMyvvS0WJc5vRnPz0+9qrgOcARqCpfn0qJ8gTyCW+ETLOoxzcdIgLdyd1AgwE2XopuaK/HBxwauKUXDFzQv7vD3J6pslujQMKgmjbqQ1mBX4m1mJqbSyZLkwZ0g/nnOoQBZ/2OP6x4punKS6DUm14FdNEM/aY9aig9MNlOe/fDMn1Lr1ZsfEosTiEZUbcqvCOb6OsHKy896ZgdRbUJx1XBExb/eYkcOesO5I1kBt1rOZR4Iv9P/LAoYy03U5lypDANrQ4w+WMSg8N2NGN5CVBVguJOklUmUpbx5HKzsVQdcm/e9Yv4wME8K3+JcV2Y940oxBTXnsEO3olpDO4sCA3QgjthbkNtMqmwwG20VI4L8vM/ZFaf4VvJzkjuGbVqgmgoPsDnD3Uh0/UfA1v7J2mJqEkQehtbB3x rOVJ9KII UPkYUokOJFulTT4+D+JIzVE7BncgB1yE0VPsoxzXdHWe0uqiQ7NDeGnmw1ScIdovYcBSrRD5KBTO9aER2wiGnB2vO1RGJrtB9TsgBD3cp4HjHWqn+dqeIqLuY9RlkNivaHMjpOw4OYMC9mf/ZTzjnCFm8C2q67M9fWvvCxlbapa2M3D2lqwJh5WijoZigFqP/3Q4vPU4X7uEKOsDe7telaqADr4fRJlSjOdEEBbZPJJZUe2q2tX/++NByt2xXA4+irdCAgvhoZMrwY0v7SLXBfqJHkXNRbyFqKwJZYsA1HL5gD4vwebhvR/EvxvT/Su33ESFPvn7mrM8zMyAI1AsOkNmGBKApDIxC6CtJJGLxFXN81ZtznnG2Ausukm8ZJzl46D+kMrDN7mqW6ZsFQivrIj4uVZ65uZ7WvpNGH2vwWb3a3ruMC7yp6K9/8ZflcuCUhgbC X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This code was converted from using find_lock_page() which returns NULL, to calling filemap_lock_hugetlb_folio() which returns -ENOENT. The check needs to be updated to match. Also IS_ERR() has an unlikely() built in so we can remove that. Fixes: 4649d8d5bb81 ("mm/filemap: remove hugetlb special casing in filemap.c") Signed-off-by: Dan Carpenter Reviewed-by: Sidhartha Kumar --- filemap_lock_hugetlb_folio() can return NULL if huge tables are disabled but that isn't the case here so there is no need to check for that. fs/hugetlbfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c index 3f2f0a4bfad0..91034b6e5b69 100644 --- a/fs/hugetlbfs/inode.c +++ b/fs/hugetlbfs/inode.c @@ -354,7 +354,7 @@ static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to) /* Find the folio */ folio = filemap_lock_hugetlb_folio(h, mapping, index); - if (unlikely(folio == NULL)) { + if (IS_ERR(folio)) { /* * We have a HOLE, zero out the user-buffer for the * length of the hole or request.