Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Apr 2018 20:18:10 +0000 (UTC)
From:      "Jonathan T. Looney" <jtl@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r332842 - stable/11/sys/netinet6
Message-ID:  <201804202018.w3KKIAw7032048@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jtl
Date: Fri Apr 20 20:18:10 2018
New Revision: 332842
URL: https://svnweb.freebsd.org/changeset/base/332842

Log:
  MFC r319216:
    Fix an unnecessary/incorrect check in the PKTOPT_EXTHDRCPY macro.
  
    This macro allocates memory and, if malloc does not return NULL, copies
    data into the new memory. However, it doesn't just check whether malloc
    returns NULL. It also checks whether we called malloc with M_NOWAIT. That
    is not necessary.
  
    While it may be that malloc() will only return NULL when the M_NOWAIT flag
    is set, we don't need to check for this when checking malloc's return
    value. Further, in this case, the check was not completely accurate,
    because it checked for flags == M_NOWAIT, rather than treating it as a bit
    field and checking for (flags & M_NOWAIT).
  
  Sponsored by:	Netflix, Inc.

Modified:
  stable/11/sys/netinet6/ip6_output.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/netinet6/ip6_output.c
==============================================================================
--- stable/11/sys/netinet6/ip6_output.c	Fri Apr 20 20:16:42 2018	(r332841)
+++ stable/11/sys/netinet6/ip6_output.c	Fri Apr 20 20:18:10 2018	(r332842)
@@ -2421,7 +2421,7 @@ do {\
 	if (src->type) {\
 		int hlen = (((struct ip6_ext *)src->type)->ip6e_len + 1) << 3;\
 		dst->type = malloc(hlen, M_IP6OPT, canwait);\
-		if (dst->type == NULL && canwait == M_NOWAIT)\
+		if (dst->type == NULL)\
 			goto bad;\
 		bcopy(src->type, dst->type, hlen);\
 	}\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804202018.w3KKIAw7032048>