Patchwork [BUG:1723] rpc-clnt: handle NULL dereferences

login
register
Submitter Amar Tumballi
Date 2010-09-28 16:31:38
Message ID <20100928163138.GA23176@gluster.com>
Download mbox | patch
Permalink /patch/5052/
State Accepted
Headers show

Comments

Amar Tumballi - 2010-09-28 16:31:38
Signed-off-by: Amar Tumballi <amar@gluster.com>
---
 rpc/rpc-lib/src/rpc-clnt.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
Vijay Bellur - 2010-09-29 04:49:52
Reviewed OK.

Regards,
Vijay

On Tuesday 28 September 2010 10:01 PM, Amar Tumballi wrote:
> Signed-off-by: Amar Tumballi<amar@gluster.com>
> ---
>   rpc/rpc-lib/src/rpc-clnt.c |   18 +++++++++++-------
>   1 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
> index 856fcfb..3019dae 100644
> --- a/rpc/rpc-lib/src/rpc-clnt.c
> +++ b/rpc/rpc-lib/src/rpc-clnt.c
> @@ -325,15 +325,17 @@ saved_frames_unwind (struct saved_frames *saved_frames)
>                             sizeof(timestr) - strlen (timestr),
>                             ".%"GF_PRI_SUSECONDS, trav->saved_at.tv_usec);
>
> -		gf_log ("rpc-clnt", GF_LOG_ERROR,
> -			"forced unwinding frame type(%s) op(%s(%d)) "
> +                if (!trav->rpcreq || !trav->rpcreq->prog)
> +                        continue;
> +
> +                gf_log ("rpc-clnt", GF_LOG_ERROR,
> +                        "forced unwinding frame type(%s) op(%s(%d)) "
>                           "called at %s",
> -			trav->rpcreq->prog->progname,
> +                        trav->rpcreq->prog->progname,
>                           (trav->rpcreq->prog->procnames) ?
>                           trav->rpcreq->prog->procnames[trav->rpcreq->procnum]
>                           : "--",
>                           trav->rpcreq->procnum, timestr);
> -
>   		saved_frames->count--;
>
>                   trav->rpcreq->rpc_status = -1;
> @@ -1401,9 +1403,11 @@ out:
>           }
>
>           if (frame&&  (ret == -1)) {
> -                rpcreq->rpc_status = -1;
> -                cbkfn (rpcreq, NULL, 0, frame);
> -                mem_put (rpc->reqpool, rpcreq);
> +                if (rpcreq) {
> +                        rpcreq->rpc_status = -1;
> +                        cbkfn (rpcreq, NULL, 0, frame);
> +                        mem_put (rpc->reqpool, rpcreq);
> +                }
>           }
>           return ret;
>   }
>

Patch

diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 856fcfb..3019dae 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -325,15 +325,17 @@  saved_frames_unwind (struct saved_frames *saved_frames)
                           sizeof(timestr) - strlen (timestr),
                           ".%"GF_PRI_SUSECONDS, trav->saved_at.tv_usec);
 
-		gf_log ("rpc-clnt", GF_LOG_ERROR,
-			"forced unwinding frame type(%s) op(%s(%d)) "
+                if (!trav->rpcreq || !trav->rpcreq->prog)
+                        continue;
+
+                gf_log ("rpc-clnt", GF_LOG_ERROR,
+                        "forced unwinding frame type(%s) op(%s(%d)) "
                         "called at %s",
-			trav->rpcreq->prog->progname,
+                        trav->rpcreq->prog->progname,
                         (trav->rpcreq->prog->procnames) ?
                         trav->rpcreq->prog->procnames[trav->rpcreq->procnum]
                         : "--",
                         trav->rpcreq->procnum, timestr);
-
 		saved_frames->count--;
 
                 trav->rpcreq->rpc_status = -1;
@@ -1401,9 +1403,11 @@  out:
         }
 
         if (frame && (ret == -1)) {
-                rpcreq->rpc_status = -1;
-                cbkfn (rpcreq, NULL, 0, frame);
-                mem_put (rpc->reqpool, rpcreq);
+                if (rpcreq) {
+                        rpcreq->rpc_status = -1;
+                        cbkfn (rpcreq, NULL, 0, frame);
+                        mem_put (rpc->reqpool, rpcreq);
+                }
         }
         return ret;
 }