From patchwork Mon Jan 22 22:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526328 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 5A78BC46CD2 for ; Mon, 22 Jan 2024 22:32:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DBCD8D0006; Mon, 22 Jan 2024 17:32:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 367938D0003; Mon, 22 Jan 2024 17:32:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B5F08D0006; Mon, 22 Jan 2024 17:32:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 09BE58D0003 for ; Mon, 22 Jan 2024 17:32:54 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D881DA1EFC for ; Mon, 22 Jan 2024 22:32:53 +0000 (UTC) X-FDA: 81708398226.28.BB1831F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 3147C100011 for ; Mon, 22 Jan 2024 22:32:52 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hIusVaAI; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962772; a=rsa-sha256; cv=none; b=HoQPuOWcIg/Ap5+MGnjNNwzTnuG21ktfZPVb13eHT3L9bBE8aGcUAjS0Nd8y6AwJD5n6Z8 jGQtTR10mNcM+G9Yom0xV84xC9wYUvcJx93Er2X/azOR72RbAuhz2uDmJfRPo/OLM6UB4P bJGfy+ojZHWkjvXFukZvuVLveyIkmSE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hIusVaAI; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705962772; 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=dTDK7i2Q4hPQnzfb2SdByLYJyeMyokMSiVdAUDeKcK0=; b=2WQwsOk/h/opTGDoxAJgT/+rFCG39afBdNCMCCj7turs3P6XW8S2pc1nAsAkPlyLVgRd03 zX5fGVYT+cnkK3Lv9sWs2WAPjFmgJY0OhgeROILDjuB9MLvdj6FGceUuaSihj9F9XrMrHg a86heY+8KfsIxuMjKGAAP507WniX8qw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962771; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dTDK7i2Q4hPQnzfb2SdByLYJyeMyokMSiVdAUDeKcK0=; b=hIusVaAItMpqSk2euRjzOS670x1BBqvyAXUS1n3Pugao+Mc2ThLCETgd2Di2AK2zsTl8th DTEfywQzCNhjPLgbVXhaeiHkFqK+RZ7ObBBatLmTLZwTgcDXtGgufwvYTPChPk4txIgv3G xKEacD9FTDkQa1Gs9+Ud8aIQAVMgdtI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-Qkey4K3HML2HB-kO-l1Q7Q-1; Mon, 22 Jan 2024 17:32:48 -0500 X-MC-Unique: Qkey4K3HML2HB-kO-l1Q7Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A62011C0418A; Mon, 22 Jan 2024 22:32:47 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80C1F1C060B1; Mon, 22 Jan 2024 22:32:45 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dan Carpenter Subject: [PATCH v2 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() Date: Mon, 22 Jan 2024 22:32:18 +0000 Message-ID: <20240122223230.4000595-6-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3147C100011 X-Stat-Signature: kperk8gadwykecio3k9xqdnt1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PGTxnLwXUrBqM9EMCR5gDBlGRNwwBY9O5Rp2iIbdEZrbegXhCZG2tSLkq6VafJycFZXdlgykA9iwaWDyY1a9pdnL+7u7Ip8cePcEPBJqWH5U1XlexKCY+a1xGV3beGracK4pIm4coQY0giSI5Ksohdrl6kcUI3ZBWjKfGlEys4y7hkkhFfYc5ZtTGaaVTvNE7uk18lVo/3FbmXxjOvefRy2ztzII3UPEOiIt9yY7UucdDbhUHgJgxKGlYtuYPmcXVEA/C0zdyij1HzylLcZuama0pncgvx/63uV27/hnDSphV8Rz6kO9EpcNL/6nixDr+g0= 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: List-Subscribe: List-Unsubscribe: From: Dan Carpenter The netfs_grab_folio_for_write() function doesn't return NULL, it returns error pointers. Update the check accordingly. Fixes: c38f4e96e605 ("netfs: Provide func to copy data to pagecache for buffered write") Signed-off-by: Dan Carpenter Signed-off-by: David Howells Link: https://lore.kernel.org/r/29fb1310-8e2d-47ba-b68d-40354eb7b896@moroto.mountain/ --- fs/netfs/buffered_write.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index e7f9ba6fb16b..a3059b3168fd 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -221,10 +221,11 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, if (unlikely(fault_in_iov_iter_readable(iter, part) == part)) break; - ret = -ENOMEM; folio = netfs_grab_folio_for_write(mapping, pos, part); - if (!folio) + if (IS_ERR(folio)) { + ret = PTR_ERR(folio); break; + } flen = folio_size(folio); offset = pos & (flen - 1);