From patchwork Fri Nov 17 21:15:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13459388 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 51695C072A2 for ; Fri, 17 Nov 2023 21:16:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D99F38D001E; Fri, 17 Nov 2023 16:16:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D49118D001C; Fri, 17 Nov 2023 16:16:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BEC7E8D001E; Fri, 17 Nov 2023 16:16:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id AC5F18D001C for ; Fri, 17 Nov 2023 16:16:55 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8D2BFC06F1 for ; Fri, 17 Nov 2023 21:16:55 +0000 (UTC) X-FDA: 81468705990.12.98697C5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id AB9871C001A for ; Fri, 17 Nov 2023 21:16:53 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V8d7D6J0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1700255813; 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=q1lktkYNGRwJVdqEsqa3bBbzKXmPaXBUD45wayN6YC17eyNL4B+Gc6KgV4Ng+K+yl+vsWW qi56i8r8SdxJVrd4rcoU5WnPlvqZ/20XClmWX82GsSNnMTEq7ee7zcBcJ2L5mUdAD2zyGQ Z/XK3QOqkDJiVh7u0jpVUGU87WVJvt0= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=V8d7D6J0; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700255813; a=rsa-sha256; cv=none; b=eSMt/PtscPX3EDsM7ss0Kp0Vyf8B5hNyOYPr/RbY6KamgROTOifh5nVSDiNYycC3doqwHT WS5+UbvPLsekGDqef8Ff7GIPKOeoWCm/nnOWI5aChagIywa4SCCn2mH443dnwuxV2s0u55 28hK6u9l/VNNjmNgNz7oN9MTJ+bNGlI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700255813; 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=V8d7D6J0IQ/wJFs+ntSufQ7PNNukkHiVEXXN4zrHp0Jy/5lkXfw8T/tkm6KnCJSH+KEiox kgWdTRrxohzYp8dw46Jw32Qg8GQtjnYPuMJY0/ew0IhjxMUyKgi5R4w53YNiYDFYc6NNje RnbIqNS3hXC4il+mL8kg84hg5KduE30= 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-86-rHs7fDMYPGmnOtXv9QHMRA-1; Fri, 17 Nov 2023 16:16:47 -0500 X-MC-Unique: rHs7fDMYPGmnOtXv9QHMRA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 9122C1C06361; Fri, 17 Nov 2023 21:16:46 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.16]) by smtp.corp.redhat.com (Postfix) with ESMTP id F2A8040C6EBB; Fri, 17 Nov 2023 21:16:43 +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 , 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 v2 17/51] netfs: Make netfs_put_request() handle a NULL pointer Date: Fri, 17 Nov 2023 21:15:09 +0000 Message-ID: <20231117211544.1740466-18-dhowells@redhat.com> In-Reply-To: <20231117211544.1740466-1-dhowells@redhat.com> References: <20231117211544.1740466-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Rspamd-Queue-Id: AB9871C001A X-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tmQ1o jXS+GgLIIA8MKcWAfHo5k73pvA8YlcZ42ttIjrF3DIGaiIqlIXHxZ6iYvU9J34c89J3qZ179LJW/Sq4JqcbxoDcutwq/C2O/H6UZQy0TcYovVXHO1m+A9se0sUkvrzgFzSySDJeQ5g6csfEih7xsZEICJ76hvKCzJl0for9/72V5MacV0v1Xg8smh4R1J8EjbkxzqHJroimohA+8EBOEQD9VxBmte3cNU0rJtVeWETxHpVHeugJxJXCdkcoGCCVGppruebR5rqSuUbdJMjNgqInsyPqxkMSh9sf5k3bt5OZLqbi79YUeoW/8Ut8Cqsz/qtdel95YABLTXAKyl37Nxh72GoQ== 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); + } } } }