浏览代码

IPv6: datagram_send_ctl() should exit immediately when an error occured

When an error occured, datagram_send_ctl() should exit immediately rather than
continue to run the for loop. Otherwise, the variable err might be changed and
the error might be hidden.

Fix this bug by using "goto" instead of "break".

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Miao Xie 17 年之前
父节点
当前提交
4a36702e01
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      net/ipv6/datagram.c

+ 1 - 1
net/ipv6/datagram.c

@@ -732,7 +732,7 @@ int datagram_send_ctl(struct net *net,
 			LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n",
 				       cmsg->cmsg_type);
 			err = -EINVAL;
-			break;
+			goto exit_f;
 		}
 	}