Hi,

Coverty complains that the return value of sblock() is not checked
in sorflush(), but in other places it is.  See CID 1453099.

The flags SB_NOINTR and M_WAITOK should avoid failure.  As I am
trying to find a race in this area for years, I would like to put
an assert here.

ok?

bluhm

Index: kern/uipc_socket.c
===================================================================
RCS file: /data/mirror/openbsd/cvs/src/sys/kern/uipc_socket.c,v
retrieving revision 1.203
diff -u -p -r1.203 uipc_socket.c
--- kern/uipc_socket.c  1 Sep 2017 15:05:31 -0000       1.203
+++ kern/uipc_socket.c  7 Sep 2017 21:18:20 -0000
@@ -1041,9 +1041,12 @@ sorflush(struct socket *so)
        struct sockbuf *sb = &so->so_rcv;
        struct protosw *pr = so->so_proto;
        struct socket aso;
+       int error;
 
        sb->sb_flags |= SB_NOINTR;
-       sblock(so, sb, M_WAITOK);
+       error = sblock(so, sb, M_WAITOK);
+       /* with SB_NOINTR and M_WAITOK sblock() must not fail */
+       KASSERT(error == 0);
        socantrcvmore(so);
        sbunlock(sb);
        aso.so_proto = pr;

Reply via email to