From patchwork Thu Dec 7 21:21:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13484042 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 E1001C10DCE for ; Thu, 7 Dec 2023 21:23:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8DED36B00AE; Thu, 7 Dec 2023 16:23:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88DA56B00AF; Thu, 7 Dec 2023 16:23:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E0686B00B0; Thu, 7 Dec 2023 16:23:31 -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 594AA6B00AF for ; Thu, 7 Dec 2023 16:23:31 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 309D9120276 for ; Thu, 7 Dec 2023 21:23:31 +0000 (UTC) X-FDA: 81541298622.20.162B021 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 607B440018 for ; Thu, 7 Dec 2023 21:23:29 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XG0fPomb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701984209; 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=i1NCs1wijkp9oudHg0v3ZW2pY0xP/Retx1SxWP1fmpE=; b=aKYD5KQR62tjtfr6p1hjYJlWxkba/UMROKs/S7Jv4NXAm7QNqf3VFWOX9H03fXsdfu3yfk ungkElRpoVSNzRMXl13lGfqee4ptrHLT8rbqvlasZqe7ZUiOlofQ3CsxOk+YHlCJid6Hzr R+sNyeSFpPZnYP6oaKgOVcyg3FHOrgY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XG0fPomb; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701984209; a=rsa-sha256; cv=none; b=q3jJ32aEizU/TA4c923MxrrRN4SSeIce9tRL0Sx+aH7Eg88+mWl4uyRBfTgmPLYSR1FzpO G03KRQN3Thw+uyacZ/TW5Ua+5JgsWtbv//cXOqwAx2Dv7ILcrSLEF50XcsYq/p6IokuwQf dOz/E0AVw4PBIuNoKFfDjpawExLdJHA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701984208; 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=i1NCs1wijkp9oudHg0v3ZW2pY0xP/Retx1SxWP1fmpE=; b=XG0fPombv/E0pYKucwRxuMejJXPfiyxUNJ/aJMNTVZiQqXi/dmaMA+JBdC6d4m5QTynlUY Rq0CCvpMaodwBVvsRmbyg3r6oBfTKllB2mIIWDvB4HnGhenjCwngJThbrtbZHRzawte9cL YZMkeORGSxajn+sKsx5DQL/HpGELBCY= 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-613-_pwwI_YRN4GTpksMjMzvlA-1; Thu, 07 Dec 2023 16:23:25 -0500 X-MC-Unique: _pwwI_YRN4GTpksMjMzvlA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 6D04410B9340; Thu, 7 Dec 2023 21:23:24 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id C4FB72026D66; Thu, 7 Dec 2023 21:23:21 +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 v3 21/59] netfs: Make netfs_put_request() handle a NULL pointer Date: Thu, 7 Dec 2023 21:21:28 +0000 Message-ID: <20231207212206.1379128-22-dhowells@redhat.com> In-Reply-To: <20231207212206.1379128-1-dhowells@redhat.com> References: <20231207212206.1379128-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Rspam-User: X-Rspamd-Server: rspam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XsonteZmSzkWRtreAN5jEUP+YmM7XQoLDL4+DboqPIrm+kiLBrCDR9OlPj5QrWlIFQjVAH4sPt2Js8vYgwYtEfJ5RptZCENCjkpsC+bqJp5x+Pp7XKE8s7OIhgurT4OFCFP9ext9NeXcWor0rRuY3U1eeH56KC9YxzumPo1KkC6htPEw4Cv9Qu0IYw4UnO7PazQMZvmVjd+GQDYfX0Ean8EmkFpyFTvMNqg0TUTbjumOHu9ZhvdgSnxUfbi69laKzN3n2uesTbfU/BREfKfAP54I2rf3+dkNsXb2aO1mycXeV87/WlwWoCGaGqLDDdkfMdyAXfQvOS4dNnPt8g== 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 cc: 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 7ef804e8915c..3ce6313cc5f9 100644 --- a/fs/netfs/objects.c +++ b/fs/netfs/objects.c @@ -109,19 +109,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); + } } } }