From patchwork Thu Dec 21 13:23:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13501934 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 4FEB4C35274 for ; Thu, 21 Dec 2023 13:25:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5F2B8D001E; Thu, 21 Dec 2023 08:25:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0E616B0098; Thu, 21 Dec 2023 08:25:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C88DD8D001E; Thu, 21 Dec 2023 08:25:34 -0500 (EST) 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 B44E96B0096 for ; Thu, 21 Dec 2023 08:25:34 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8AEC9C0651 for ; Thu, 21 Dec 2023 13:25:34 +0000 (UTC) X-FDA: 81590897388.29.CF0A60A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id ADDB11A001C for ; Thu, 21 Dec 2023 13:25:32 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E1dedVFT; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1703165132; 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=U/y+xm2N9V1erDz4QIGlE5zRDPNtyRW7a99pDjZCrtc=; b=pgwBZOOzMjQ/paYGwn4M/5xJFxu8tISaypcXFyteIbhyJFgE9yT1W1fFBTHEsomU153jrp Gn+P3edwiz8jr/a5rL7fdlvJIhLPkArAL5B/lCEgpIwa6nLu/HarX8Njh8iiJ9zGJLuC8b bJcVNrmLYFmFCDFbQJMjPwoy/O2FI1g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703165132; a=rsa-sha256; cv=none; b=qR4Ff9OplK67behcnnxPrnY5nfqFnMeuL3spqz8dEQ8Txr+jKUqOCDyBKlkIZI6cb4hl0f 16oTpZzVwG1Gmr+cn0S+CpvoAyTOA5oawF85vwpN8CPhIWUND/YQl70I3bcezUeqXgKnfZ ZmM9gbUdTgkug+wjD5xYu7OFhwwqRVc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=E1dedVFT; spf=pass (imf19.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703165132; 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=U/y+xm2N9V1erDz4QIGlE5zRDPNtyRW7a99pDjZCrtc=; b=E1dedVFTy1Jf7nQ3Y/Dt0wpp714eB52Kov3tQlL7UTh5hhUDnAe7XTQ4Ve5LrnOxU4UVYf Re40Iz22heGIkX5EWU7Ym9/y8u7Zsa/D6bmkB94ECijWggD5shoMwaqwSURGMbmJWcqaPK xtHaXnv51Jw6ERajDa6SN486SEK4Irk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-417-9pjKgx18P2eV28IFZ7u4ow-1; Thu, 21 Dec 2023 08:25:27 -0500 X-MC-Unique: 9pjKgx18P2eV28IFZ7u4ow-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 4A30185A58B; Thu, 21 Dec 2023 13:25:26 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.39.195.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6425F51D5; Thu, 21 Dec 2023 13:25:23 +0000 (UTC) From: David Howells To: Jeff Layton , Steve French Cc: David Howells , Matthew Wilcox , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Dominique Martinet , Eric Van Hensbergen , Ilya Dryomov , Christian Brauner , linux-cachefs@redhat.com, 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-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 21/40] netfs: Make netfs_put_request() handle a NULL pointer Date: Thu, 21 Dec 2023 13:23:16 +0000 Message-ID: <20231221132400.1601991-22-dhowells@redhat.com> In-Reply-To: <20231221132400.1601991-1-dhowells@redhat.com> References: <20231221132400.1601991-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Stat-Signature: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r+b6T38No h5Gks5hr G3uWHpTaK7pbnXzu8tJzDAct1Ir5HeTaf5eJm7/ATR90GNg9UNY0QlfjlO5gb6g5Zfpc8vvuPOu1hQpc/EzjsysiuoXeGutYVZiwq0TVSNQsT4hrxDi4B6d498X3N/WE3FcoH2WfyLhQS/VItwzXmFA+DAGVzJg+Gr9KG9Et83kCTE1DwAPxwMu3JJgdbZzDjIcpeYuK1/BTthZ/s1Oq9b5Ofqv7SA3XW09qxi/L10oyxteNeDqEd+ZMxyKzw0zG9QCpKr6UurDeswtYEEJHpd6r9RgXF3y/dpEJwt3okuNMdkovBeIRlipdvgCQRBIRwvnrRVy7wt6oSIRVmNaYtHDC05w== 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: Make netfs_put_request() just return if given a NULL request pointer. Signed-off-by: David Howells Reviewed-by: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/objects.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c index 65a17dd4ab49..3aa0bfbc04ec 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -106,19 +106,22 @@ static void netfs_free_request(struct work_struct *work) void netfs_put_request(struct netfs_io_request *rreq, bool was_async, enum netfs_rreq_ref_trace what) { - unsigned int debug_id = rreq->debug_id; + unsigned int debug_id; bool dead; int r; - dead = __refcount_dec_and_test(&rreq->ref, &r); - trace_netfs_rreq_ref(debug_id, r - 1, what); - if (dead) { - if (was_async) { - rreq->work.func = netfs_free_request; - if (!queue_work(system_unbound_wq, &rreq->work)) - BUG(); - } else { - netfs_free_request(&rreq->work); + if (rreq) { + debug_id = rreq->debug_id; + dead = __refcount_dec_and_test(&rreq->ref, &r); + trace_netfs_rreq_ref(debug_id, r - 1, what); + if (dead) { + if (was_async) { + rreq->work.func = netfs_free_request; + if (!queue_work(system_unbound_wq, &rreq->work)) + BUG(); + } else { + netfs_free_request(&rreq->work); + } } } }