OSDN Git Service

cifs: fix kref underflow in close_shroot()
authorRonnie Sahlberg <lsahlber@redhat.com>
Thu, 28 Mar 2019 01:20:02 +0000 (11:20 +1000)
committerSteve French <stfrench@microsoft.com>
Mon, 1 Apr 2019 19:33:30 +0000 (14:33 -0500)
commit2f94a3125b8742b05a011d62b16f52eb8f9ebe1c
treef32e1140c6857b8d6d751bb014fbe4c5793a9d57
parent5e7a8ca319268a70a6c7c3c1fde5bea38e1e5539
cifs: fix kref underflow in close_shroot()

Fix a bug where we used to not initialize the cached fid structure at all
in open_shroot() if the open was successful but we did not get a lease.
This would leave the structure uninitialized and later when we close the handle
we would in close_shroot() try to kref_put() an uninitialized refcount.

Fix this by always initializing this structure if the open was successful
but only do the extra get() if we got a lease.
This extra get() is only used to hold the structure until we get a lease
break from the server at which point we will kref_put() it during lease
processing.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
CC: Stable <stable@vger.kernel.org>
fs/cifs/smb2ops.c