linux-stable/net/sunrpc
Xin Xiong c0434f0e05 net/sunrpc: fix potential memory leaks in rpc_sysfs_xprt_state_change()
commit bfc48f1b05 upstream.

The issue happens on some error handling paths. When the function
fails to grab the object `xprt`, it simply returns 0, forgetting to
decrease the reference count of another object `xps`, which is
increased by rpc_sysfs_xprt_kobj_get_xprt_switch(), causing refcount
leaks. Also, the function forgets to check whether `xps` is valid
before using it, which may result in NULL-dereferencing issues.

Fix it by adding proper error handling code when either `xprt` or
`xps` is NULL.

Fixes: 5b7eb78486 ("SUNRPC: take a xprt offline using sysfs")
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-08-25 11:40:23 +02:00
..
auth_gss SUNRPC: Ensure that the gssproxy client can start in a connected state 2022-05-18 10:26:56 +02:00
xprtrdma SUNRPC: Trap RDMA segment overflows 2022-06-14 18:36:16 +02:00
addr.c nfsd: don't alloc under spinlock in rpc_parse_scope_id 2021-11-18 19:16:58 +01:00
auth.c sunrpc: fix expiry of auth creds 2022-08-25 11:40:05 +02:00
auth_null.c
auth_unix.c
backchannel_rqst.c SUNRPC: Reinitialise the backchannel request buffers before reuse 2022-08-25 11:40:05 +02:00
cache.c
clnt.c sunrpc: set cl_max_connect when cloning an rpc_clnt 2022-06-22 14:21:59 +02:00
debugfs.c
fail.h
Kconfig
Makefile
netns.h
rpc_pipe.c fsnotify: fix fsnotify hooks in pseudo filesystems 2022-02-01 17:27:01 +01:00
rpcb_clnt.c
sched.c SUNRPC: remove scheduling boost for "SWAPPER" tasks. 2022-04-13 20:59:12 +02:00
socklib.c
socklib.h
stats.c
sunrpc.h
sunrpc_syms.c
svc.c NFSD: Have legacy NFSD WRITE decoders use xdr_stream_subsegment() 2022-03-08 19:12:33 +01:00
svc_xprt.c SUNRPC: Fix NFSD's request deferral on RDMA transports 2022-04-20 09:34:18 +02:00
svcauth.c
svcauth_unix.c
svcsock.c SUNRPC: svc_tcp_sendmsg() should handle errors from xdr_alloc_bvec() 2022-04-13 20:59:20 +02:00
sysctl.c
sysfs.c net/sunrpc: fix potential memory leaks in rpc_sysfs_xprt_state_change() 2022-08-25 11:40:23 +02:00
sysfs.h
timer.c
xdr.c SUNRPC: Fix READ_PLUS crasher 2022-07-07 17:53:25 +02:00
xprt.c SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() 2022-05-18 10:26:57 +02:00
xprtmultipath.c
xprtsock.c SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() 2022-05-18 10:26:57 +02:00