Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9088645pxu; Mon, 28 Dec 2020 06:21:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJzoQUtC8So+YsheWDXYVMhvXTBGaFr2gDxa5K7n3tkZvKuuMbYjvMTmoVl1RjpQylBDL2Ld X-Received: by 2002:a50:a6de:: with SMTP id f30mr43474240edc.30.1609165274596; Mon, 28 Dec 2020 06:21:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165274; cv=none; d=google.com; s=arc-20160816; b=ixxf53PGZbi0DZEd3+nO1A0AHWqpUYkVhkfMS3xYjHH65t4B0NaX3BoCDJ2OQmvh5s A80fUHgQzrZRyeplftArIj5dHot0NkXLlQZy7GE/LOHIZKToJil/ByZzsYmopwOoaFRA PvAvaCuw+2yly6pMN8gMEfPUW+slPDz9jc8eJfuXelSnC1+dzH9+rmuMpKoRvZfqEgGx ZG8gn8ULzJ5jLn4buc6xMkPJ8/fYJX+FfLf46MPPxd2u5FL4buAeo3ESIGZ74mkN0G7T YMaB6aMC6Uyl7KYSussTM6w+MxnvCxsT4QjqVyOmeaNVOxm9Nkh/833iu0zqEoQCeGbw CbVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pQ5BIAN6bku6mAzq9QpBjdno98s8bkn4annTgWFQYh8=; b=nktCGwZERgF2ECPNA5C9/QquIS8XQEBy3yoQptLdjTnOgrHYR8IojdmpsYKb+PVnZa fC5mJXxKsBcKWewYUdn86qyuu0ywoFVp3+YMWDYYqZkf+mpHU+V2Lmm2UbkW2DsRitSR HaNfNGQmx8+nVGXihMKc9qEoLzNhaNgaLLdq+Iay4Bsn3eMCija0macY9sRIrnNfMlnd XfMzOqrsl1eQ1Bco7ExxqRyetmf4kgGZhlp7IxvdY+cyKnSa82l+KA1BblvUmjoqGQAx 76pAQAW6ON7XzUJOON2iZkVHekb6Ad5/zgcN7vqh5i/PuA0Snc92KV34AYy7rdSftJhw pIpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FpaiWdsg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si18183858eje.526.2020.12.28.06.20.52; Mon, 28 Dec 2020 06:21:14 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FpaiWdsg; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2441571AbgL1OTE (ORCPT + 99 others); Mon, 28 Dec 2020 09:19:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:54324 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440595AbgL1OTD (ORCPT ); Mon, 28 Dec 2020 09:19:03 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 43822229C4; Mon, 28 Dec 2020 14:18:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165102; bh=pbv/90rDytlLbLe153ID88PZs21iMaEh9hAlauAntUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FpaiWdsg1nB6pNUjBHmBxAHDw05EfsoMDyzu3sPJ7d/xrA3drT0dPnfhOJx6bxX0a CjbLJ1BcIrvvR1SEX/gZdGJFMfdKQudKauLWKpATnUyeKmRIxMKtv5ub/W3puLPW/2 52D/Arb5Ggi2/kC6vUrigmxeXpfshuOTZjGk1bXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Xiongfeng Wang , Sasha Levin Subject: [PATCH 5.10 382/717] misc: pci_endpoint_test: fix return value of error branch Date: Mon, 28 Dec 2020 13:46:20 +0100 Message-Id: <20201228125039.304254225@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiongfeng Wang [ Upstream commit 1749c90489f2afa6b59dbf3ab59d58a9014c84a1 ] 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 Link: https://lore.kernel.org/r/1605790158-6780-1-git-send-email-wangxiongfeng2@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- 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 146ca6fb3260f..d3844730eacaf 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; -- 2.27.0