From patchwork Wed Dec 25 07:47:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangweidong X-Patchwork-Id: 305097 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 758532C00A0 for ; Wed, 25 Dec 2013 18:48:47 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751332Ab3LYHsZ (ORCPT ); Wed, 25 Dec 2013 02:48:25 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:39229 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751025Ab3LYHsY (ORCPT ); Wed, 25 Dec 2013 02:48:24 -0500 Received: from 172.24.2.119 (EHLO szxeml209-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BPA12288; Wed, 25 Dec 2013 15:47:50 +0800 (CST) Received: from SZXEML420-HUB.china.huawei.com (10.82.67.159) by szxeml209-edg.china.huawei.com (172.24.2.184) with Microsoft SMTP Server (TLS) id 14.3.158.1; Wed, 25 Dec 2013 15:47:48 +0800 Received: from [127.0.0.1] (10.177.18.75) by szxeml420-hub.china.huawei.com (10.82.67.159) with Microsoft SMTP Server id 14.3.158.1; Wed, 25 Dec 2013 15:47:48 +0800 Message-ID: <52BA8DA2.6030405@huawei.com> Date: Wed, 25 Dec 2013 15:47:46 +0800 From: Wang Weidong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 MIME-Version: 1.0 To: Neil Horman , Vlad Yasevich , David Miller CC: Subject: [PATCH net-next] sctp: check dst 'NULL' before use it in, sctp_packet_transmit X-Originating-IP: [10.177.18.75] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org skb_dst_set will use dst, if dst is NULL although is not a problem, then goto the no_route and free nskb, so do the skb_dst_set is pointless. so check dst before use it. Remove the unnecessary initialization as well. Signed-off-by: Wang Weidong --- net/sctp/output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sctp/output.c b/net/sctp/output.c index 3be70a4..9b76d62 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c @@ -387,7 +387,7 @@ int sctp_packet_transmit(struct sctp_packet *packet) int err = 0; int padding; /* How much padding do we need? */ __u8 has_data = 0; - struct dst_entry *dst = tp->dst; + struct dst_entry *dst; unsigned char *auth = NULL; /* pointer to auth in skb data */ pr_debug("%s: packet:%p\n", __func__, packet); @@ -420,9 +420,9 @@ int sctp_packet_transmit(struct sctp_packet *packet) } } dst = dst_clone(tp->dst); - skb_dst_set(nskb, dst); if (!dst) goto no_route; + skb_dst_set(nskb, dst); /* Build the SCTP header. */ sh = (struct sctphdr *)skb_push(nskb, sizeof(struct sctphdr));