From patchwork Wed Jan 10 18:54:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 186991 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp989690dyi; Wed, 10 Jan 2024 10:56:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IHfqjfUnLuqoyYVab3+70iVtlWsn/3OWS/9sEIfla20VtkD4o5cPMnvRFQrbEMdgb3VCmeI X-Received: by 2002:a05:6a00:8d86:b0:6d9:b7ef:466c with SMTP id im6-20020a056a008d8600b006d9b7ef466cmr59606pfb.67.1704912989001; Wed, 10 Jan 2024 10:56:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704912988; cv=none; d=google.com; s=arc-20160816; b=cWLY8QyxC02Modvvt0EjCHH3yuo86zcE8xps15Uhj4zwj/x+bpanmq7TuD/Cbe8Khi jgabb8J/3uP6MQvM9/KCx6f7H6UZjoRGgcV6ir24gBSJYI8B622VxkgVc3nDtwVEsuWJ yOKw1fAb4+h1qt4Omkgv1Y9+hF1GvuTD7C11sKHnD8AY3+Y5U1TBykhp6wcEU3H/7YJY fSVoQuJpaWsKuZtnAda8fsT8BwfBRDbsVlGYUSXb79AIb9uhJ47VjZff2CrZbP6svypg gGUHDH5ErDzWBi9DYGgRF7N5qBMXXz3jtkhO+WRM6MhKSbHegEyf9Nvs6AIUEAQOp55l +Jhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=ZN9Wo59ib8rrxmGmkNNqnPBXMYJ/gbEqO2erlBDFegk=; fh=4w0k4zVhqW9jlsTg9mDjqWCrDARODZ/tl3I9ViGgISo=; b=cg+C8QIkDRrkxoUTBmGoXh9A2d2MtFJ0kvIPXFyLL/H7vmbUymhU82+JKqYDs1uabc lPgoYl2AHFwKz+60wVDUZojdrGl8AgVei0UBDH3iKMhQpm9rvM0xW0jViHCNLN9rZ6xl 8yvaamAko1kPWI96X9zugNadYSmFcpiGrYRX7bNeKxCrOPD3uDlsCWmt0dCmMtaM7N3k 42A+N8K6J6P/KcyRgClwswxZCGNm6igurZovE4G9olidRx2Qa+Mf5QMcpzer0gTqu1Ll thtPFcBJkeeLwxIC23otJJvlBHwvbUjXgQ5La6m2v+i9lWyQUQQ9+92d4hBokPWmtmkS yMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1pJ7uAZ; spf=pass (google.com: domain of linux-kernel+bounces-22619-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22619-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b15-20020a056a000a8f00b006dad7f283f8si4365564pfl.23.2024.01.10.10.56.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 10:56:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22619-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1pJ7uAZ; spf=pass (google.com: domain of linux-kernel+bounces-22619-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22619-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7C689B26274 for ; Wed, 10 Jan 2024 18:55:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41FC64D5BA; Wed, 10 Jan 2024 18:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="H1pJ7uAZ" Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 159184CDE8 for ; Wed, 10 Jan 2024 18:54:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-40e461c1f5cso41098315e9.3 for ; Wed, 10 Jan 2024 10:54:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1704912885; x=1705517685; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=ZN9Wo59ib8rrxmGmkNNqnPBXMYJ/gbEqO2erlBDFegk=; b=H1pJ7uAZ/WvGsOGgHHd+lbhQUFMdCRJ5yM91bcgbZG20RwJWbL4bpYvEzQLMV5CiCu sku1Nxgr+Lu3iDe4A+sgs7J0wDBkY+RZL7TwVxVrTk+gP7l4J4YTHQjePoks+qMh/Pvc WUipjJweNSq7uSIA6e2hI7AyuYCX4Uo/NcTsp06Hg0VZuGDCFaAIxDb5hfh5/8QHHYHQ S+C87mF3C5MKLDlDUbnYtbzOAeLlr/Guy/dhIxo+Z4a2aO7uzmqLnU6NtnwdhoDJdU5s Dm6sACHTHdHlObZK7LyQNWF55a9IE0d8jzNEQ4wnIEKB38tkzoTkjNLW+pKOMfa7sSRh VmIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704912885; x=1705517685; 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=ZN9Wo59ib8rrxmGmkNNqnPBXMYJ/gbEqO2erlBDFegk=; b=qzwIWQ2o8kQvaTAhETcoRHLNWpKi0URN0q7n9x4utu0splF5L1Jifw00jweVMwVdKn 5p9aIWlLVQr3q4v1O6dkp+p+3Jp37m3Dn+6RgjwGE2FLJecTCexeHP4lkTith8gOuKid zR1LtYkb2UknD+ZCSdXLTkDb/sc6JUjZ2eZ1T545HRjjJlsgSCrQqZcBtM+i22e/28m6 X/th+4YIZhH+0LLe9UfUzzkc39E3CHrBiAadVYaywhFYANrEhOvN5Sg7kxQ8akcNtsq9 pQW3T/67eIIzjrilEl1uGtcn5lgC9b+DY9vo3N00IQeX5ALaIgXaQ/Z67d2tI0JH8qLr 4LNg== X-Gm-Message-State: AOJu0YyXZwGbNRH0WWvmP7oUTE9SQTXy+Xcn4PyiQQoUc9w2p2/Gxofa 9nR2jlM7zBjlUWDWW4FdVyNowf33PA7wtgd5MdeJEPokMHg= X-Received: by 2002:a7b:cd10:0:b0:40d:86a8:2fe9 with SMTP id f16-20020a7bcd10000000b0040d86a82fe9mr573312wmj.280.1704912885337; Wed, 10 Jan 2024 10:54:45 -0800 (PST) Received: from localhost ([102.140.209.237]) by smtp.gmail.com with ESMTPSA id h5-20020a05600c350500b0040e55ee7fa7sm3173186wmq.8.2024.01.10.10.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 10:54:45 -0800 (PST) Date: Wed, 10 Jan 2024 21:54:42 +0300 From: Dan Carpenter To: David Howells Cc: linux-cachefs@redhat.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() Message-ID: <29fb1310-8e2d-47ba-b68d-40354eb7b896@moroto.mountain> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787730842317102667 X-GMAIL-MSGID: 1787730842317102667 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 --- 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 a69e6e655320..25d861702bd8 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -205,10 +205,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);