OSDN Git Service

cifs: Fix some error pointers handling detected by static checker
authorSamuel Cabrero <scabrero@suse.de>
Tue, 15 Dec 2020 16:46:56 +0000 (17:46 +0100)
committerSteve French <stfrench@microsoft.com>
Tue, 15 Dec 2020 21:13:47 +0000 (15:13 -0600)
commit09a8361e3b681ef6b56cc56f7b2905b4455d6774
tree3e74c1404183a0b5cf69c59bce8daad477224ee3
parentdd538034f84fa4ea670420aac19adcceef45d057
cifs: Fix some error pointers handling detected by static checker

* extract_hostname() and extract_sharename() never return NULL, so
  use IS_ERR() instead of IS_ERR_OR_NULL() in cifs_find_swn_reg(). If
  any of these functions return an error, then return an error pointer
  instead of NULL.
* Change cifs_find_swn_reg() function to always return a valid pointer
  or an error pointer, instead of returning NULL if the registration
  is not found.
* Finally update cifs_find_swn_reg() callers to check for -EEXIST
  instead of NULL.
* In cifs_get_swn_reg() the swnreg idr mutex was not unlocked in the
  error path of cifs_find_swn_reg() call.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Samuel Cabrero <scabrero@suse.de>
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/cifs_swn.c