Skip to content

Commit 8e5d112

Browse files
Z1naX5namjaejeon
authored andcommitted
ksmbd: fix refcount leak causing resource not released
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. Signed-off-by: Ziyan Xu <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent 5e4a4b8 commit 8e5d112

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

oplock.c

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

1323-
if (ksmbd_conn_releasing(opinfo->conn))
1323+
if (ksmbd_conn_releasing(opinfo->conn)) {
1324+
opinfo_put(opinfo);
13241325
continue;
1326+
}
13251327

13261328
oplock_break(opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL);
13271329
opinfo_put(opinfo);
@@ -1357,8 +1359,11 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp)
13571359
if (!atomic_inc_not_zero(&opinfo->refcount))
13581360
continue;
13591361

1360-
if (ksmbd_conn_releasing(opinfo->conn))
1362+
if (ksmbd_conn_releasing(opinfo->conn)) {
1363+
opinfo_put(opinfo);
13611364
continue;
1365+
}
1366+
13621367
oplock_break(opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL);
13631368
opinfo_put(opinfo);
13641369
}
@@ -1561,8 +1566,10 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
15611566
if (!atomic_inc_not_zero(&brk_op->refcount))
15621567
continue;
15631568

1564-
if (ksmbd_conn_releasing(brk_op->conn))
1569+
if (ksmbd_conn_releasing(brk_op->conn)) {
1570+
opinfo_put(brk_op);
15651571
continue;
1572+
}
15661573

15671574
#ifdef CONFIG_SMB_INSECURE_SERVER
15681575
if (brk_op->is_smb2) {

0 commit comments

Comments
 (0)