2015-07-09 13:59:33

by ditang chen

[permalink] [raw]
Subject: [PATCH] [patch]libtirpc: check the makefd_xprt return value

xprt may return NULL, so check the return value is necessary.

Signed-off-by: Ditang Chen <[email protected]>
---
src/svc_vc.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/src/svc_vc.c b/src/svc_vc.c
index 9824631..f864951 100644
--- a/src/svc_vc.c
+++ b/src/svc_vc.c
@@ -337,6 +337,8 @@ again:
*/

newxprt = makefd_xprt(sock, r->sendsize, r->recvsize);
+ if (!newxprt)
+ return (FALSE);

if (!__rpc_set_netbuf(&newxprt->xp_rtaddr, &addr, len))
return (FALSE);
--
1.9.3


2015-07-13 14:27:39

by Chuck Lever

[permalink] [raw]
Subject: Re: [PATCH] [patch]libtirpc: check the makefd_xprt return value


> On Jul 9, 2015, at 9:59 AM, ditang chen <[email protected]> wrote:
>
> xprt may return NULL, so check the return value is necessary.

This would only happen if the malloc() calls in makefd_xprt() failed,
which I think would be exceptionally rare?

Otherwise, this change adds reasonable defensive coding.

Reviewed-by: Chuck Lever <[email protected]>


> Signed-off-by: Ditang Chen <[email protected]>
> ---
> src/svc_vc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/svc_vc.c b/src/svc_vc.c
> index 9824631..f864951 100644
> --- a/src/svc_vc.c
> +++ b/src/svc_vc.c
> @@ -337,6 +337,8 @@ again:
> */
>
> newxprt = makefd_xprt(sock, r->sendsize, r->recvsize);
> + if (!newxprt)
> + return (FALSE);
>
> if (!__rpc_set_netbuf(&newxprt->xp_rtaddr, &addr, len))
> return (FALSE);
> --
> 1.9.3
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Chuck Lever
[email protected]




2015-07-13 14:37:10

by Steve Dickson

[permalink] [raw]
Subject: Re: [PATCH] [patch]libtirpc: check the makefd_xprt return value



On 07/09/2015 09:59 AM, ditang chen wrote:
> xprt may return NULL, so check the return value is necessary.
>
> Signed-off-by: Ditang Chen <[email protected]>
Committed... Thanks!

steved.

> ---
> src/svc_vc.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/svc_vc.c b/src/svc_vc.c
> index 9824631..f864951 100644
> --- a/src/svc_vc.c
> +++ b/src/svc_vc.c
> @@ -337,6 +337,8 @@ again:
> */
>
> newxprt = makefd_xprt(sock, r->sendsize, r->recvsize);
> + if (!newxprt)
> + return (FALSE);
>
> if (!__rpc_set_netbuf(&newxprt->xp_rtaddr, &addr, len))
> return (FALSE);
>