09e69a
commit 4a2d85c64110ee9e21a8c4f9dafd6b0ae621506d
09e69a
Author: Zhi Li <yieli@redhat.com>
09e69a
Date:   Fri Oct 28 14:19:04 2022 -0400
09e69a
09e69a
    clnt_raw.c: fix a possible null pointer dereference
09e69a
    
09e69a
    Since clntraw_private could be dereferenced before
09e69a
    allocated, protect it by checking its value in advance.
09e69a
    
09e69a
    Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2138317
09e69a
    Signed-off-by: Zhi Li <yieli@redhat.com>
09e69a
    Signed-off-by: Steve Dickson <steved@redhat.com>
09e69a
09e69a
diff --git a/src/clnt_raw.c b/src/clnt_raw.c
09e69a
index 31f9d0c..03f839d 100644
09e69a
--- a/src/clnt_raw.c
09e69a
+++ b/src/clnt_raw.c
09e69a
@@ -142,7 +142,7 @@ clnt_raw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
09e69a
 	struct timeval timeout;
09e69a
 {
09e69a
 	struct clntraw_private *clp = clntraw_private;
09e69a
-	XDR *xdrs = &clp->xdr_stream;
09e69a
+	XDR *xdrs;
09e69a
 	struct rpc_msg msg;
09e69a
 	enum clnt_stat status;
09e69a
 	struct rpc_err error;
09e69a
@@ -154,6 +154,7 @@ clnt_raw_call(h, proc, xargs, argsp, xresults, resultsp, timeout)
09e69a
 		mutex_unlock(&clntraw_lock);
09e69a
 		return (RPC_FAILED);
09e69a
 	}
09e69a
+	xdrs = &clp->xdr_stream;
09e69a
 	mutex_unlock(&clntraw_lock);
09e69a
 
09e69a
 call_again:
09e69a
@@ -245,7 +246,7 @@ clnt_raw_freeres(cl, xdr_res, res_ptr)
09e69a
 	void *res_ptr;
09e69a
 {
09e69a
 	struct clntraw_private *clp = clntraw_private;
09e69a
-	XDR *xdrs = &clp->xdr_stream;
09e69a
+	XDR *xdrs;
09e69a
 	bool_t rval;
09e69a
 
09e69a
 	mutex_lock(&clntraw_lock);
09e69a
@@ -254,6 +255,7 @@ clnt_raw_freeres(cl, xdr_res, res_ptr)
09e69a
 		mutex_unlock(&clntraw_lock);
09e69a
 		return (rval);
09e69a
 	}
09e69a
+	xdrs = &clp->xdr_stream;
09e69a
 	mutex_unlock(&clntraw_lock);
09e69a
 	xdrs->x_op = XDR_FREE;
09e69a
 	return ((*xdr_res)(xdrs, res_ptr));