From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6B5D6A04C7; Tue, 15 Sep 2020 13:57:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 155AF1BF59; Tue, 15 Sep 2020 13:57:50 +0200 (CEST) Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by dpdk.org (Postfix) with ESMTP id A3BD1DE0; Tue, 15 Sep 2020 13:57:48 +0200 (CEST) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 224C3F0FE5E9F9739323; Tue, 15 Sep 2020 19:57:47 +0800 (CST) Received: from localhost (10.174.185.168) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Tue, 15 Sep 2020 19:57:41 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang , Date: Tue, 15 Sep 2020 19:57:40 +0800 Message-ID: <1600171060-30200-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.185.168] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2] bus/dpaa: fix fd check before close X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Yunjian Wang The fd is possibly a negative value while it is passed as an argument to function "close". Fix the check to the fd. Fixes: b9c94167904f ("bus/dpaa: decouple FQ portal alloc and init") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang --- v2: Remove duplicated check suggested by Ferruh Yigit --- drivers/bus/dpaa/base/qbman/qman_driver.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/bus/dpaa/base/qbman/qman_driver.c b/drivers/bus/dpaa/base/qbman/qman_driver.c index a466c698f..6d9aaff16 100644 --- a/drivers/bus/dpaa/base/qbman/qman_driver.c +++ b/drivers/bus/dpaa/base/qbman/qman_driver.c @@ -142,7 +142,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd) struct qm_portal_config *q_pcfg; struct dpaa_ioctl_irq_map irq_map; struct dpaa_ioctl_portal_map q_map = {0}; - int q_fd = 0, ret; + int q_fd, ret; q_pcfg = kzalloc((sizeof(struct qm_portal_config)), 0); if (!q_pcfg) { @@ -179,7 +179,7 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd) if (!portal) { pr_err("Qman portal initialisation failed (%d)\n", q_pcfg->cpu); - goto err; + goto err_alloc; } irq_map.type = dpaa_portal_qman; @@ -188,9 +188,9 @@ struct qman_portal *fsl_qman_fq_portal_create(int *fd) *fd = q_fd; return portal; +err_alloc: + close(q_fd); err: - if (q_fd) - close(q_fd); process_portal_unmap(&q_map.addr); kfree(q_pcfg); return NULL; -- 2.23.0