Skip to content

Commit

Permalink
net: kcm: Replace fput with sockfd_put
Browse files Browse the repository at this point in the history
The function sockfd_lookup uses fget on the value that is stored in
the file field of the returned structure, so fput should ultimately be
applied to this value.  This can be done directly, but it seems better
to use the specific macro sockfd_put, which does the same thing.

Perform a source code refactoring by using the following semantic patch.

    // <smpl>
    @@
    expression s;
    @@

       s = sockfd_lookup(...)
       ...
    + sockfd_put(s);
    - fput(s->file);
    // </smpl>

Signed-off-by: Zheng Yongjun <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Zheng Yongjun authored and davem330 committed Jan 6, 2021
1 parent 8407b23 commit 8dc879a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/kcm/kcmsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ static int kcm_attach_ioctl(struct socket *sock, struct kcm_attach *info)

return 0;
out:
fput(csock->file);
sockfd_put(csock);
return err;
}

Expand Down Expand Up @@ -1644,7 +1644,7 @@ static int kcm_unattach_ioctl(struct socket *sock, struct kcm_unattach *info)
spin_unlock_bh(&mux->lock);

out:
fput(csock->file);
sockfd_put(csock);
return err;
}

Expand Down

0 comments on commit 8dc879a

Please sign in to comment.