[LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create()
Chuck Lever
chuck.lever@oracle.com
Thu Sep 26 15:41:41 CEST 2024
On Thu, Sep 26, 2024 at 12:13:58PM +0800, Ma Xinjian wrote:
> Determine the return value of clnt_create() to avoid segmentation fault
> when executing clnt_destroy() when the return value of create is NULL.
>
> Signed-off-by: Ma Xinjian <maxj.fnst@fujitsu.com>
> ---
> .../tirpc/tirpc_toplevel_clnt_destroy/tirpc_clnt_destroy.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_clnt_destroy/tirpc_clnt_destroy.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_clnt_destroy/tirpc_clnt_destroy.c
> index 939ff3e4a..bb9a47503 100644
> --- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_clnt_destroy/tirpc_clnt_destroy.c
> +++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_clnt_destroy/tirpc_clnt_destroy.c
> @@ -58,6 +58,13 @@ int main(int argn, char *argc[])
> //first create client
> clnt = clnt_create(argc[1], progNum, VERSNUM, nettype);
>
> + if (clnt == NULL) {
> + clnt_pcreateerror("err");
> + printf("%d\n", rpc_createerr.cf_stat);
> +
> + return 1;
> + }
> +
> //then call destroy macro
> clnt_destroy(clnt);
>
> --
> 2.42.0
>
That's the basic idea. And then apply the same fix to other tests
that call the clnt_create(3) APIs.
Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
--
Chuck Lever
More information about the ltp
mailing list