Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp95651imm; Thu, 2 Aug 2018 23:41:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfOnkwAL6KN+0vVmbaA1jwq3GwbO5dw5239hrGLlphuDkSyXMlAoDz7wp1zESV8ceWgCoR6 X-Received: by 2002:a63:e318:: with SMTP id f24-v6mr2356899pgh.175.1533278464285; Thu, 02 Aug 2018 23:41:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533278464; cv=none; d=google.com; s=arc-20160816; b=Ynh1XdAd9SaoUwdJb3Yxx4PnOxwd0jMJYteES48+kptc3rNax8JWXLdKDbYLg+IL31 M5hbkgFTz/FeAG45suADVO/UlJC0ZNeFGuNZ7gRmlg1cJNDya6IYIG/FnDBYzcYTyG5+ QUC1zhHKcMIXh8fygD4Mtvl1J8qo5y220Rfu+KJM4F2jrEMMCpuZx+n2rlxOAsjVWI1w ZEzWWPSsnbZxnoAZjNcbbOdDGZjU+ofphxZxxr0ob4MLSZIeKDZI1BLOD450MmRHw8Ps uPAsdpB0qRt20lHxR+SryOiAygmjPpbhghyspRW62hPJKBUyifGX/Lh3PmcKeYfXJf6i QISA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=EhxRMLjowl+vC1ebPrx8oXDyWLURGuKePe1eWUwRiEY=; b=rbT5C5KJsmiBfZYpH3wu7GodGb+/6i3dGa8r5F4VIWT2SYlwAECwiKHPMht09ppToY sJA48KFTy5lTOIqYKzcvwqc+7V+z0W0KjA3RTQCJMaFy2mHEcsSGQpWXRYxQhy7PXk1L Aw9sOq1HhRhizAbuIB6jfuXchENn+BfGZzsM8AbpeOYP98fm64YOUzYumrfaBDTuPy71 GjciEhOwoSLXSlrRxaVQ+m2O/p5+DRzI0lf/DZCWtDpNxvJ9Pk607sWqBiJbsCPy2bNs RWJ+hzA8tGHaNqrHp1JVw45/o+q2vdOTSA/ARiqrr/ZuH57mi7oBs6XcgYtqEXouOgvp /kQw== 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 f8-v6si4313852pgf.166.2018.08.02.23.40.49; Thu, 02 Aug 2018 23:41:04 -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 S1728037AbeHCIes (ORCPT + 99 others); Fri, 3 Aug 2018 04:34:48 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:10619 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726833AbeHCIer (ORCPT ); Fri, 3 Aug 2018 04:34:47 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A79A747C5AD49; Fri, 3 Aug 2018 14:39:56 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Fri, 3 Aug 2018 14:39:51 +0800 From: YueHaibing To: , , , , CC: , , YueHaibing Subject: [PATCH] um: NULL check before kfree is not needed Date: Fri, 3 Aug 2018 14:39:11 +0800 Message-ID: <20180803063911.23384-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kfree(NULL) is safe,so this removes NULL check before freeing the mem Signed-off-by: YueHaibing --- arch/um/drivers/vector_kern.c | 15 +++++---------- arch/um/drivers/vector_user.c | 6 ++---- arch/um/kernel/irq.c | 3 +-- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index 50ee3bb..c84133c 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c @@ -1118,16 +1118,11 @@ static int vector_net_close(struct net_device *dev) os_close_file(vp->fds->tx_fd); vp->fds->tx_fd = -1; } - if (vp->bpf != NULL) - kfree(vp->bpf); - if (vp->fds->remote_addr != NULL) - kfree(vp->fds->remote_addr); - if (vp->transport_data != NULL) - kfree(vp->transport_data); - if (vp->header_rxbuffer != NULL) - kfree(vp->header_rxbuffer); - if (vp->header_txbuffer != NULL) - kfree(vp->header_txbuffer); + kfree(vp->bpf); + kfree(vp->fds->remote_addr); + kfree(vp->transport_data); + kfree(vp->header_rxbuffer); + kfree(vp->header_txbuffer); if (vp->rx_queue != NULL) destroy_queue(vp->rx_queue); if (vp->tx_queue != NULL) diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c index 4d6a78e..3d8cdbd 100644 --- a/arch/um/drivers/vector_user.c +++ b/arch/um/drivers/vector_user.c @@ -267,8 +267,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec) os_close_file(rxfd); if (txfd >= 0) os_close_file(txfd); - if (result != NULL) - kfree(result); + kfree(result); return NULL; } @@ -434,8 +433,7 @@ static struct vector_fds *user_init_socket_fds(struct arglist *ifspec, int id) if (fd >= 0) os_close_file(fd); if (result != NULL) { - if (result->remote_addr != NULL) - kfree(result->remote_addr); + kfree(result->remote_addr); kfree(result); } return NULL; diff --git a/arch/um/kernel/irq.c b/arch/um/kernel/irq.c index 6b7f382..8360fa3 100644 --- a/arch/um/kernel/irq.c +++ b/arch/um/kernel/irq.c @@ -244,8 +244,7 @@ static void garbage_collect_irq_entries(void) to_free = NULL; } walk = walk->next; - if (to_free != NULL) - kfree(to_free); + kfree(to_free); } } -- 2.7.0