Skip to content

Commit d01e56a

Browse files
q2venintel-lab-lkp
authored andcommitted
af_unix: Remove redundant scm->fp check in __scm_destroy().
__scm_destroy() is called from __scm_recv_common() or scm_destroy(), and both of which check if scm->fp is NULL. Let's remove the redundant scm->fp check in __scm_destroy(). While at it, we remove EXPORT_SYMBOL() for it and rename it to scm_fp_destroy() to make the following patch clearer. Signed-off-by: Kuniyuki Iwashima <[email protected]>
1 parent 9ab249c commit d01e56a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

include/net/scm.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct scm_cookie {
5353
void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm);
5454
void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm);
5555
int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm);
56-
void __scm_destroy(struct scm_cookie *scm);
56+
void scm_fp_destroy(struct scm_cookie *scm);
5757
struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl);
5858

5959
#ifdef CONFIG_SECURITY_NETWORK
@@ -84,8 +84,9 @@ static __inline__ void scm_destroy_cred(struct scm_cookie *scm)
8484
static __inline__ void scm_destroy(struct scm_cookie *scm)
8585
{
8686
scm_destroy_cred(scm);
87+
8788
if (scm->fp)
88-
__scm_destroy(scm);
89+
scm_fp_destroy(scm);
8990
}
9091

9192
static __inline__ int scm_send(struct socket *sock, struct msghdr *msg,

net/compat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
326326
* All of the files that fit in the message have had their usage counts
327327
* incremented, so we just free the list.
328328
*/
329-
__scm_destroy(scm);
329+
scm_fp_destroy(scm);
330330
}
331331

332332
/* Argument list sizes for compat_sys_socketcall */

net/core/scm.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,20 +130,19 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp)
130130
return num;
131131
}
132132

133-
void __scm_destroy(struct scm_cookie *scm)
133+
void scm_fp_destroy(struct scm_cookie *scm)
134134
{
135135
struct scm_fp_list *fpl = scm->fp;
136136
int i;
137137

138-
if (fpl) {
139-
scm->fp = NULL;
140-
for (i=fpl->count-1; i>=0; i--)
141-
fput(fpl->fp[i]);
142-
free_uid(fpl->user);
143-
kfree(fpl);
144-
}
138+
scm->fp = NULL;
139+
140+
for (i = fpl->count - 1; i >= 0; i--)
141+
fput(fpl->fp[i]);
142+
143+
free_uid(fpl->user);
144+
kfree(fpl);
145145
}
146-
EXPORT_SYMBOL(__scm_destroy);
147146

148147
int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
149148
{
@@ -375,7 +374,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
375374
* All of the files that fit in the message have had their usage counts
376375
* incremented, so we just free the list.
377376
*/
378-
__scm_destroy(scm);
377+
scm_fp_destroy(scm);
379378
}
380379
EXPORT_SYMBOL(scm_detach_fds);
381380

0 commit comments

Comments
 (0)