* [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create()
@ 2024-09-26 4:13 Ma Xinjian via ltp
2024-09-26 13:41 ` Chuck Lever via ltp
2024-09-27 2:12 ` Hanxiao Chen (Fujitsu) via ltp
0 siblings, 2 replies; 4+ messages in thread
From: Ma Xinjian via ltp @ 2024-09-26 4:13 UTC (permalink / raw)
To: ltp, chuck.lever, chenhx.fnst
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create()
2024-09-26 4:13 [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create() Ma Xinjian via ltp
@ 2024-09-26 13:41 ` Chuck Lever via ltp
2024-10-21 12:22 ` Petr Vorel
2024-09-27 2:12 ` Hanxiao Chen (Fujitsu) via ltp
1 sibling, 1 reply; 4+ messages in thread
From: Chuck Lever via ltp @ 2024-09-26 13:41 UTC (permalink / raw)
To: Ma Xinjian; +Cc: ltp
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
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create()
2024-09-26 13:41 ` Chuck Lever via ltp
@ 2024-10-21 12:22 ` Petr Vorel
0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2024-10-21 12:22 UTC (permalink / raw)
To: Chuck Lever; +Cc: ltp
Hi all,
> 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.
...
> That's the basic idea. And then apply the same fix to other tests
> that call the clnt_create(3) APIs.
Thanks a lot for fix and review, very much appreciated.
@Ma Xinjian or @Chen Hanxiao, could you please add this cleanup to all tests
which use clnt_create() as Chuck suggested?
Kind regards,
Petr
> Reviewed-by: Chuck Lever <chuck.lever@oracle.com>
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create()
2024-09-26 4:13 [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create() Ma Xinjian via ltp
2024-09-26 13:41 ` Chuck Lever via ltp
@ 2024-09-27 2:12 ` Hanxiao Chen (Fujitsu) via ltp
1 sibling, 0 replies; 4+ messages in thread
From: Hanxiao Chen (Fujitsu) via ltp @ 2024-09-27 2:12 UTC (permalink / raw)
To: Xinjian Ma (Fujitsu), ltp@lists.linux.it, chuck.lever@oracle.com
> -----邮件原件-----
> 发件人: Ma Xinjian <maxj.fnst@fujitsu.com>
> 发送时间: 2024年9月26日 12:14
> 收件人: ltp@lists.linux.it; chuck.lever@oracle.com; Chen, Hanxiao
> <chenhx.fnst@fujitsu.com>
> 抄送: Ma, Xinjian <maxj.fnst@fujitsu.com>
> 主题: [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create()
>
> 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_cl
> nt_destroy/tirpc_clnt_destroy.c
> b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_cl
> nt_destroy/tirpc_clnt_destroy.c
> index 939ff3e4a..bb9a47503 100644
> ---
> a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_cl
> nt_destroy/tirpc_clnt_destroy.c
> +++
> b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/tirpc/tirpc_toplevel_cl
> nt_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);
>
With the patch above, no segfault found
And logs look better:
rpc_test 1 TINFO: 192.168.122.147/24 -- 192.168.122.148/24
rpc_test 1 TINFO: fd00::1/64 -- fd00::2/64
rpc_test 1 TINFO: timeout per run is 0h 10m 0s
rpc_test 1 TINFO: check registered RPC with rpcinfo
rpc_test 1 TINFO: registered RPC:
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
rpc_test 1 TINFO: using libtirpc: yes
rpc_test 1 TFAIL: tirpc_clnt_destroy 192.168.122.147 536875000 failed unexpectedly
12
err: RPC: Remote system error - No route to host
Tested-by: Chen Hanxiao <chenhx.fnst@fujitsu.com>
Regards,
- Chen
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-21 12:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 4:13 [LTP] [PATCH] tirpc_clnt_destroy: Determine the return value of clnt_create() Ma Xinjian via ltp
2024-09-26 13:41 ` Chuck Lever via ltp
2024-10-21 12:22 ` Petr Vorel
2024-09-27 2:12 ` Hanxiao Chen (Fujitsu) via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox