Skip to content

Commit 9a7abce

Browse files
Z1naX5gregkh
authored andcommitted
ksmbd: fix refcount leak causing resource not released
commit 89bb430 upstream. When ksmbd_conn_releasing(opinfo->conn) returns true,the refcount was not decremented properly, causing a refcount leak that prevents the count from reaching zero and the memory from being released. Cc: stable@vger.kernel.org Signed-off-by: Ziyan Xu <ziyan@securitygossip.com> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fd1896d commit 9a7abce

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

fs/smb/server/oplock.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,8 +1102,10 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,
11021102
if (!atomic_inc_not_zero(&opinfo->refcount))
11031103
continue;
11041104

1105-
if (ksmbd_conn_releasing(opinfo->conn))
1105+
if (ksmbd_conn_releasing(opinfo->conn)) {
1106+
opinfo_put(opinfo);
11061107
continue;
1108+
}
11071109

11081110
oplock_break(opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL);
11091111
opinfo_put(opinfo);
@@ -1139,8 +1141,11 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp)
11391141
if (!atomic_inc_not_zero(&opinfo->refcount))
11401142
continue;
11411143

1142-
if (ksmbd_conn_releasing(opinfo->conn))
1144+
if (ksmbd_conn_releasing(opinfo->conn)) {
1145+
opinfo_put(opinfo);
11431146
continue;
1147+
}
1148+
11441149
oplock_break(opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL);
11451150
opinfo_put(opinfo);
11461151
}
@@ -1343,8 +1348,10 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
13431348
if (!atomic_inc_not_zero(&brk_op->refcount))
13441349
continue;
13451350

1346-
if (ksmbd_conn_releasing(brk_op->conn))
1351+
if (ksmbd_conn_releasing(brk_op->conn)) {
1352+
opinfo_put(brk_op);
13471353
continue;
1354+
}
13481355

13491356
if (brk_op->is_lease && (brk_op->o_lease->state &
13501357
(~(SMB2_LEASE_READ_CACHING_LE |

0 commit comments

Comments
 (0)