Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp425380pxb; Thu, 19 Nov 2020 05:01:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrX794vRRa7hdvY3XMPxSUj5OqCzETGtHvOQiyhU9kgwLV0RRZ/Y7wt4MNpuowTv/+vxje X-Received: by 2002:aa7:ce82:: with SMTP id y2mr31056356edv.6.1605790913767; Thu, 19 Nov 2020 05:01:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605790913; cv=none; d=google.com; s=arc-20160816; b=n4yXFlJqoXXw3PnGsyaxqzLdfUsf8n15ytQMbI5yHA42dKhF2A0uT7/ZPJUVb/FAie QKUAyNQnaJrPzF/gq8rmzNbs5zD3ms7nbV6ZJRrXAveF8UUTWzrVy5IMPWDPr15r2+yA bx9nYj09DftJP7CNcKUNEDTKOKcShAIM0v593ldCSUOcljbp880KMqV36Q3SdGORl7h8 lQdivp0YBD8Xwhp6bVo37uKyzYyx8hD85n16uGazGhe7xZoBlO5yFoEmn/wWz90ZYH30 FHqyvQ+4aDCXBKBK64kpUtI99RQAxRvwHzF2ciHcfbKW3xN/+n94cdUWoBOSmfYeMsWp 4xYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=jxGjUyDno0065kzYL8ObINEmlonBPd0IRWwGv+kpa5k=; b=oF8ml+YFCB100uyEGeZFUD2Dgt69EwEsRZ95dyaDs8IO5JEiAbGY89AT3bB+zf8bUw I/sPCis8Ebshuywo/symzN7OMavL3U/0nRaLKxqGcfPuu1u+HNLyI/4iF2wbz/3GPTlh YMKPB2hsUS4hOjyYWwk63V4AkgQ8hhbesCSZXJUEHlN/AqwqR1igmLpqmgViWe4D7TYJ OCFJGevhAjFDUvOjwYg84/o+OCTzRoBOIa6rG9kV9LYVhGsq4ohf1j7BgBEYDmPhSFqA Blb6frGw8du0Kum5IPIoYsoxojS5tli8KR0E+9XxHmrhyv5pvWvP3DluZGFmrCKDq5Pq C0FA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si14181024eja.279.2020.11.19.05.01.22; Thu, 19 Nov 2020 05:01:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727364AbgKSM5r (ORCPT + 99 others); Thu, 19 Nov 2020 07:57:47 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8122 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727048AbgKSM5r (ORCPT ); Thu, 19 Nov 2020 07:57:47 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CcKTH03pJzLqKp; Thu, 19 Nov 2020 20:57:23 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Thu, 19 Nov 2020 20:57:37 +0800 From: Xiongfeng Wang To: , , , , CC: , , Subject: [PATCH] misc: pci_endpoint_test: fix return value of error branch Date: Thu, 19 Nov 2020 20:49:18 +0800 Message-ID: <1605790158-6780-1-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We return 'err' in the error branch, but this variable may be set as zero before. Fix it by setting 'err' as a negative value before we goto the error label. Fixes: e03327122e2c ("pci_endpoint_test: Add 2 ioctl commands") Reported-by: Hulk Robot Signed-off-by: Xiongfeng Wang --- drivers/misc/pci_endpoint_test.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c index 146ca6f..d384473 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -811,8 +811,10 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, pci_set_master(pdev); - if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) + if (!pci_endpoint_test_alloc_irq_vectors(test, irq_type)) { + err = -EINVAL; goto err_disable_irq; + } for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) { if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) { @@ -849,8 +851,10 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, goto err_ida_remove; } - if (!pci_endpoint_test_request_irq(test)) + if (!pci_endpoint_test_request_irq(test)) { + err = -EINVAL; goto err_kfree_test_name; + } misc_device = &test->miscdev; misc_device->minor = MISC_DYNAMIC_MINOR; -- 1.7.12.4