public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thiago Rafael Becker <trbecker@gmail.com>
To: linux-nfs@vger.kernel.org
Cc: Thiago Rafael Becker <tbecker@redhat.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna.schumaker@netapp.com>,
	"J . Bruce Fields" <bfields@fieldses.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thiago Rafael Becker <trbecker@gmail.com>
Subject: [PATCH] sunrpc: bug on rpc_task_set_client when no client is present.
Date: Mon, 18 Oct 2021 09:38:12 -0300	[thread overview]
Message-ID: <20211018123812.71482-1-trbecker@gmail.com> (raw)

If we pass a NULL client to rpc_task_set_client and no client is
attached to the task, then the kernel will crash later. Antecipate the
crash by checking if a client is available for the task.

Signed-off-by: Thiago Rafael Becker <trbecker@gmail.com>
---
 net/sunrpc/clnt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index f056ff931444..ccbc9a9715da 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1076,7 +1076,7 @@ void rpc_task_set_transport(struct rpc_task *task, struct rpc_clnt *clnt)
 static
 void rpc_task_set_client(struct rpc_task *task, struct rpc_clnt *clnt)
 {
-
+	BUG_ON(clnt == NULL && task->tk_client == NULL);
 	if (clnt != NULL) {
 		rpc_task_set_transport(task, clnt);
 		task->tk_client = clnt;
-- 
2.31.1


             reply	other threads:[~2021-10-18 12:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 12:38 Thiago Rafael Becker [this message]
2021-10-20 19:04 ` [PATCH] sunrpc: bug on rpc_task_set_client when no client is present Trond Myklebust
2021-10-20 20:20   ` Thiago Rafael Becker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211018123812.71482-1-trbecker@gmail.com \
    --to=trbecker@gmail.com \
    --cc=anna.schumaker@netapp.com \
    --cc=bfields@fieldses.org \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tbecker@redhat.com \
    --cc=trond.myklebust@hammerspace.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox