Skip to contentSkip to conversation

seccomp: fix poor type promotion

PATCH In review Tycho Andersen 2 participants 2 messages Dec 13, 2018 – Dec 14, 2018 Secure computing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 seccomp: fix poor type promotion

sparse complains,

kernel/seccomp.c:1172:13: warning: incorrect type in assignment (different base types)
kernel/seccomp.c:1172:13: expected restricted __poll_t [usertype] ret
kernel/seccomp.c:1172:13: got int
kernel/seccomp.c:1173:13: warning: restricted __poll_t degrades to integer

Instead of assigning this to ret, since we don't use this anywhere, let's just test it against 0 directly.

---
 kernel/seccomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/seccomp.c +1 -2
index 15b6be97fc09..d7f538847b84 100644
@@ -1169,8 +1169,7 @@ static __poll_t seccomp_notify_poll(struct file *file,
 
 	poll_wait(file, &filter->notif->wqh, poll_tab);
 
-	ret = mutex_lock_interruptible(&filter->notify_lock);
-	if (ret < 0)
+	if (mutex_lock_interruptible(&filter->notify_lock) < 0)
 		return EPOLLERR;
 
 	list_for_each_entry(cur, &filter->notif->notifications, list) {
Signature · 1 line
2.19.1
#1 lore raw
Quoted 8 lines · Tycho Andersen

sparse complains,

kernel/seccomp.c:1172:13: warning: incorrect type in assignment (different base types)
kernel/seccomp.c:1172:13: expected restricted __poll_t [usertype] ret
kernel/seccomp.c:1172:13: got int
kernel/seccomp.c:1173:13: warning: restricted __poll_t degrades to integer

Quoted 5 lines

Instead of assigning this to ret, since we don't use this anywhere, let's just test it against 0 directly.

Thanks! Added to my -next tree.

-Kees

Quoted 21 lines
---
 kernel/seccomp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/seccomp.c +1 -3
index 15b6be97fc09..d7f538847b84 100644
@@ -1169,8 +1169,7 @@ static __poll_t seccomp_notify_poll(struct file *file,
 
        poll_wait(file, &filter->notif->wqh, poll_tab);
 
-       ret = mutex_lock_interruptible(&filter->notify_lock);
-       if (ret < 0)
+       if (mutex_lock_interruptible(&filter->notify_lock) < 0)
                return EPOLLERR;
 
        list_for_each_entry(cur, &filter->notif->notifications, list) {
--

2.19.1

Signature · 1 line
Kees Cook