Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1783210imm; Thu, 20 Sep 2018 02:50:50 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2t9PIyyd7EYVJKxH4nUSCh7CEuCJ7y+o6DyixaZZV6DeT8yxB99ZpOIBc6h8Vos8JUQAZ X-Received: by 2002:a63:2703:: with SMTP id n3-v6mr3377424pgn.113.1537437050622; Thu, 20 Sep 2018 02:50:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537437050; cv=none; d=google.com; s=arc-20160816; b=X19iIaqqVxPMawmBNiZoMV1j400uf/X9++BdQ5y8Cavo0SFgqFQCTkh7xHRQXxT7R0 iezmgGbarGd7ZGk/lnV+LScHIij4PdWewqXL4tMlWe2GfSekMDDVVNyWs5Zp8InR00go fBFf4inqibjUQ6jm9SQCRJ5XjzZDhDsGXd/KByXDUGMcCC21kr+4vKISaLr/S9R0/bay 1gay1iAE+TNJ6TlRy+zdTgdBubU5KewAU8re8wq+lVt70sbEoiSwAy7l9Vkh6VsnCEik jtG41Bui51ujot4Z5j8arLD60MTzjA19i+Uk0epF0LWbFsxa9ONexXnHcvEVw1d1S7uq ZfDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=pcuQatDPWnHr5j1QO7ftHvmiSuIizrRho4od2jY4uhU=; b=ALxEV2Y6aT4G15tH8wjNFwt7MkiDOGE6Xn30Q9l+8nunbz5JIbnZ4duIxfKRisW5tF c40BxuPA7kaeuMYF8QO+DqdHIvouDIQ3zcJ0sAC/aOVVqXzfPZqPau/mK25iuipn1UwB iUk9RUu2S1L5yRKU8gofJk0VO9abJiA3/Cinqp76xXReygdg/Z1QiTm02SNcCgrH8f74 /Jau6Inj7+kUUSVd4vWhHq86RhsUflBiKqOlMosLJNtRgxdyBIovFhqoKHtXQQ7yC18U 75h99GwjaWOO7/gSok0hGAcGT2vYSQRw42OvrDbK3jIOpCuPOvMB0OeF7cF/mXrijDih HY3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t31-v6si19318654pga.167.2018.09.20.02.50.35; Thu, 20 Sep 2018 02:50:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387572AbeITPc4 (ORCPT + 99 others); Thu, 20 Sep 2018 11:32:56 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:12637 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387490AbeITPcz (ORCPT ); Thu, 20 Sep 2018 11:32:55 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C38ACAD7C13C9; Thu, 20 Sep 2018 17:50:12 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Thu, 20 Sep 2018 17:50:09 +0800 From: zhong jiang To: CC: , , , , Subject: [PATCH 1/6] net: tap: remove redundant null pointer check before kfree_skb Date: Thu, 20 Sep 2018 17:37:41 +0800 Message-ID: <1537436266-41955-2-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1537436266-41955-1-git-send-email-zhongjiang@huawei.com> References: <1537436266-41955-1-git-send-email-zhongjiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kfree_skb has taken the null pointer into account. hence it is safe to remove the redundant null pointer check before kfree_skb. Signed-off-by: zhong jiang --- drivers/net/tap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index a4ab4a7..f03004f 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -830,8 +830,7 @@ static ssize_t tap_do_read(struct tap_queue *q, ssize_t ret = 0; if (!iov_iter_count(to)) { - if (skb) - kfree_skb(skb); + kfree_skb(skb); return 0; } @@ -1236,8 +1235,7 @@ static int tap_recvmsg(struct socket *sock, struct msghdr *m, struct sk_buff *skb = m->msg_control; int ret; if (flags & ~(MSG_DONTWAIT|MSG_TRUNC)) { - if (skb) - kfree_skb(skb); + kfree_skb(skb); return -EINVAL; } ret = tap_do_read(q, &m->msg_iter, flags & MSG_DONTWAIT, skb); -- 1.7.12.4