Skip to content

Commit 776d794

Browse files
sherllyamschuma-ntap
authored andcommitted
net/sunrpc: fix reference count leaks in rpc_sysfs_xprt_state_change
The refcount leak issues take place in an error handling path. When the 3rd argument buf doesn't match with "offline", "online" or "remove", the function simply returns -EINVAL and forgets to decrease the reference count of a rpc_xprt object and a rpc_xprt_switch object increased by rpc_sysfs_xprt_kobj_get_xprt() and rpc_sysfs_xprt_kobj_get_xprt_switch(), causing reference count leaks of both unused objects. Fix this issue by jumping to the error handling path labelled with out_put when buf matches none of "offline", "online" or "remove". Signed-off-by: Xiyu Yang <[email protected]> Signed-off-by: Xin Xiong <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 4ca9f31 commit 776d794

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/sunrpc/sysfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,10 @@ static ssize_t rpc_sysfs_xprt_state_change(struct kobject *kobj,
295295
online = 1;
296296
else if (!strncmp(buf, "remove", 6))
297297
remove = 1;
298-
else
299-
return -EINVAL;
298+
else {
299+
count = -EINVAL;
300+
goto out_put;
301+
}
300302

301303
if (wait_on_bit_lock(&xprt->state, XPRT_LOCKED, TASK_KILLABLE)) {
302304
count = -EINTR;

0 commit comments

Comments
 (0)