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: 190424 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:805:b0:101:a8e8:374 with SMTP id e5csp40329dyi; Mon, 22 Jan 2024 14:35:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrwZhmvnV0EWcGXSQha+KBELWET/wQ4cqBMCCXF/FIZlHS4tC7M3ZWPHKxTptoIXRpjFjS X-Received: by 2002:a05:6870:cb89:b0:206:ce59:7a7c with SMTP id ov9-20020a056870cb8900b00206ce597a7cmr631323oab.46.1705962939750; Mon, 22 Jan 2024 14:35:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705962939; cv=pass; d=google.com; s=arc-20160816; b=K/k/oj8spUeHA34h9e6WVpLvIGO1rjYcWEUghEi/4VpzPq1jcnI+Ng0fLk2miMwCE6 6KbmH8XzI7WBE0XMq4cWt0ObJzcW+sW8EtKCEziHNBU6o4Ln6uM4HCx+z9JuN20JAwn/ JhnmD9POr3A+NbiH8YsB7P3w7iY+upDLbAfJZ9ZGn2SORrwGN3EfHAgGBLU51Ct6tz0x Wu55pVMOPwXWxjZUSK4r7qcshGi/JKRlPzODx0IZOoZrabjdSHAw6dHz+XhpNeo6gmDl stFo6tjuQY2UiipDuyTegciFbKGdDWGoIiCpSGRULnyI2dZVqImrhVX/fK9M7lO2Qq8T DpOA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=dTDK7i2Q4hPQnzfb2SdByLYJyeMyokMSiVdAUDeKcK0=; fh=8qCaggPtbUrdt/xwc3MzyndUXPJZjhBPaGYsFhspncg=; b=us7EYPm8cz4hsTbn9YQNhb7belu4b2Be35+jdhcuCnYjbXuiNUhflkhsU4y3pPIPbA QXQ38JtjXNB7n5df66osgn1JwdZavFEmM2TnO3hIRI1HKvurKTuvtmulm7KsBL6rmrK2 y9nbPIArxf36wiNDrsi+RexpEKMTMUgK4KQj6fTkFBVUTA/g0ydOGb4D+FmCyuKArZiG jvmxJDuxI3UQkPP05dnY3f9OPuFWeR57eChUAMdAshgwg6sJv2XQuxGNaRRx8hY1TYfV l1Dm5YwHKlGPhW6Mpd0anu5yJECTZeXGO8+0BM5wuIu+0W/y9aqiiS2W6FA/rl0MjJjJ 9ZDg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hIusVaAI; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-34245-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34245-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o15-20020a05622a008f00b0042a4856f84bsi1424335qtw.556.2024.01.22.14.35.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 14:35:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34245-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hIusVaAI; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-34245-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34245-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 4EB0C1C23D01 for ; Mon, 22 Jan 2024 22:35:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 623BF4B5B3; Mon, 22 Jan 2024 22:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hIusVaAI" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 5BE171096F for ; Mon, 22 Jan 2024 22:32:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705962773; cv=none; b=esY72o76BuZI5P+WrHLncKJ/N1LpWRn0iy6YZkyOvVusqFzpEmohKXso3vDUdMkhg03TcFQBHqVsGRmcKwHGPEQ6yXXX/Tf5kMknBGMtyNY7y1QHJxBfLvuLHgBvnJUDwtnV6IaMxbb0ryZNSMhzf7k5sWDZHUhWRPy1oiGHnhs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705962773; c=relaxed/simple; bh=Qn7dd9HK9v0F1KFFIftRsyM5xQPDc6YGUH7hJwsGprs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mwVE6vX4X6nIHGNkeI7nHqxgyYEj/EDtjCQDCqkt+oH6AZp9JZupdn9A5SKKUtnSjqa17m0kEKk+BbSFjph3RKgfZ236XHadfSmLw1BCfhw5fdnofYGm2HLLnJxvE40n+w1xfTug2W4Vjlh/RisPRghaTxBh8+kwG01nvREMCnw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hIusVaAI; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788831795371559346 X-GMAIL-MSGID: 1788831795371559346 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);