Skip to content

Commit f391d6e

Browse files
Dan CarpenterSteve French
authored andcommitted
cifs: Use after free in debug code
This debug code dereferences "old_iface" after it was already freed by the call to release_iface(). Re-order the debugging to avoid this issue. Fixes: b54034a ("cifs: during reconnect, update interface if necessary") Cc: stable@vger.kernel.org # 5.19+ Reviewed-by: Paulo Alcantara (SUSE) <pc@cjr.nz> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 926028a commit f391d6e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/cifs/sess.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,14 +302,14 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)
302302

303303
/* now drop the ref to the current iface */
304304
if (old_iface && iface) {
305-
kref_put(&old_iface->refcount, release_iface);
306305
cifs_dbg(FYI, "replacing iface: %pIS with %pIS\n",
307306
&old_iface->sockaddr,
308307
&iface->sockaddr);
309-
} else if (old_iface) {
310308
kref_put(&old_iface->refcount, release_iface);
309+
} else if (old_iface) {
311310
cifs_dbg(FYI, "releasing ref to iface: %pIS\n",
312311
&old_iface->sockaddr);
312+
kref_put(&old_iface->refcount, release_iface);
313313
} else {
314314
WARN_ON(!iface);
315315
cifs_dbg(FYI, "adding new iface: %pIS\n", &iface->sockaddr);

0 commit comments

Comments
 (0)