Skip to content

Commit

Permalink
cifs: Use after free in debug code
Browse files Browse the repository at this point in the history
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: [email protected] # 5.19+
Reviewed-by: Paulo Alcantara (SUSE) <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Steve French <[email protected]>
  • Loading branch information
Dan Carpenter authored and Steve French committed Nov 19, 2022
1 parent 926028a commit f391d6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/cifs/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,14 @@ cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server)

/* now drop the ref to the current iface */
if (old_iface && iface) {
kref_put(&old_iface->refcount, release_iface);
cifs_dbg(FYI, "replacing iface: %pIS with %pIS\n",
&old_iface->sockaddr,
&iface->sockaddr);
} else if (old_iface) {
kref_put(&old_iface->refcount, release_iface);
} else if (old_iface) {
cifs_dbg(FYI, "releasing ref to iface: %pIS\n",
&old_iface->sockaddr);
kref_put(&old_iface->refcount, release_iface);
} else {
WARN_ON(!iface);
cifs_dbg(FYI, "adding new iface: %pIS\n", &iface->sockaddr);
Expand Down

0 comments on commit f391d6e

Please sign in to comment.