Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp241742pxb; Wed, 18 Nov 2020 23:07:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzs+fak+hRg82J6t3X6J0oqUEIUnzFLEZmR2OvMJQlRwKJBZqMHuo0I3Yt1tA1w96aob8j X-Received: by 2002:a17:906:3782:: with SMTP id n2mr28097058ejc.493.1605769622092; Wed, 18 Nov 2020 23:07:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605769622; cv=none; d=google.com; s=arc-20160816; b=c0iDQ0WKvTVfwGyBb7I2KWCBsJZ38lWhh9jyx5ICl/nLWJf6S5uFB4gC0Q5MpT/EOH YcpCXVC8qgA3ZfCTKjt3oY78T90S3eyKd3uII3VRuXW/O3R6I3J6GfugxubOOxbMqOI1 QKN0y8OKblWggT5zs5xJ2nZ9ppwXeRCHZE65yif0Ufm8YP+XnyjNOQMv+bCyRQ3JhwXO FWCnACaILucizb/gAiXRxEfzyvq/CqjvyB2aPpnI5/8XHLk4YuKir8/hgwv3vGvXei3T HATILIYYYUL+x4kEuEaJ0aD2bbG23q/lVdhu6i3T33RWUInau9OOXNgvSK2F1jXmidlQ mZug== 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 :message-id:date:subject:cc:to:from; bh=W/17t1bTmVhPHdLSbHrPbYybi1BriM8rVVkq1beniIo=; b=CHa91xUxzlIo/dRluJLSH35y6MYMzlzTtVNUlZuu4SGDM+NxNFgNlOcUp2jGM4D+OM /FNhrv0Ln/KyM4dgAY5F1xzdSidbbZlP8ajpywY9FS27hyZu+weOngxklFnb1qz/V8rm kRZ/fCPeNHGzWzWmgMnDX4NjER2zpI42ASMEiopRVeFqtkf4HG8RxJh/FCbddNgKst53 PbOxzUt6oXAq4cRAA4Aw8VTc5KItyBrFNapNos6dMHRFOvvX2HJLe7wSjqP4oPoaRnLI T7lCXG+FlK577BSZceVN/Ech+BLvo7hJZmP0UPbIk9BEjZMKv92BVN1CGaisq1g4aOCl TZ5g== 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 i24si16451695eja.728.2020.11.18.23.06.38; Wed, 18 Nov 2020 23:07:02 -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 S1726154AbgKSHEJ (ORCPT + 99 others); Thu, 19 Nov 2020 02:04:09 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8115 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726117AbgKSHEI (ORCPT ); Thu, 19 Nov 2020 02:04:08 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Cc9dG4jk7zLnZL; Thu, 19 Nov 2020 15:03:46 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Thu, 19 Nov 2020 15:04:00 +0800 From: Qinglang Miao To: Kirti Wankhede CC: , , Qinglang Miao Subject: [PATCH] samples: vfio-mdev: fix return value of error branch in mdpy_fb_probe() Date: Thu, 19 Nov 2020 15:08:43 +0800 Message-ID: <20201119070843.1074-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org pci_release_regions() should be called in these error branches, so I set ret and use goto err_release_regions intead of simply return -EINVAL. Fixes: cacade1946a4 ("sample: vfio mdev display - guest driver") Reported-by: Hulk Robot Signed-off-by: Qinglang Miao --- samples/vfio-mdev/mdpy-fb.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c index 21dbf63d6..c944a6697 100644 --- a/samples/vfio-mdev/mdpy-fb.c +++ b/samples/vfio-mdev/mdpy-fb.c @@ -117,15 +117,18 @@ static int mdpy_fb_probe(struct pci_dev *pdev, if (format != DRM_FORMAT_XRGB8888) { pci_err(pdev, "format mismatch (0x%x != 0x%x)\n", format, DRM_FORMAT_XRGB8888); - return -EINVAL; + ret = -EINVAL; + goto err_release_regions; } if (width < 100 || width > 10000) { pci_err(pdev, "width (%d) out of range\n", width); - return -EINVAL; + ret = -EINVAL; + goto err_release_regions; } if (height < 100 || height > 10000) { pci_err(pdev, "height (%d) out of range\n", height); - return -EINVAL; + ret = -EINVAL; + goto err_release_regions; } pci_info(pdev, "mdpy found: %dx%d framebuffer\n", width, height); -- 2.23.0