Skip to content

Commit

Permalink
ksmbd: fix Null pointer dereferences in ksmbd_update_fstate()
Browse files Browse the repository at this point in the history
Coverity Scan report the following one. This report is a false alarm.
Because fp is never NULL when rc is zero. This patch add null check for fp
in ksmbd_update_fstate to make alarm silence.

*** CID 1568583:  Null pointer dereferences  (FORWARD_NULL)
/fs/smb/server/smb2pdu.c: 3408 in smb2_open()
3402                    path_put(&path);
3403                    path_put(&parent_path);
3404            }
3405            ksmbd_revert_fsids(work);
3406     err_out1:
3407            if (!rc) {
>>>     CID 1568583:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "fp" to "ksmbd_update_fstate", which dereferences it.
3408                    ksmbd_update_fstate(&work->sess->file_table, fp, FP_INITED);
3409                    rc = ksmbd_iov_pin_rsp(work, (void *)rsp, iov_len);
3410            }
3411            if (rc) {
3412                    if (rc == -EINVAL)
3413                            rsp->hdr.Status = STATUS_INVALID_PARAMETER;

Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Oct 10, 2023
1 parent 2cfac5e commit 76b4e77
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vfs_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,9 @@ struct ksmbd_file *ksmbd_open_fd(struct ksmbd_work *work, struct file *filp)
void ksmbd_update_fstate(struct ksmbd_file_table *ft, struct ksmbd_file *fp,
unsigned int state)
{
if (!fp)
return;

write_lock(&ft->lock);
fp->f_state = state;
write_unlock(&ft->lock);
Expand Down

0 comments on commit 76b4e77

Please sign in to comment.