Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4849970pxj; Wed, 9 Jun 2021 03:30:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCClLdMVJeo41TdAbLF3GOxXL9SjzLgGNS5yrKnj8a1K6W75wbdWlZDWs6xg2q4Mg3lgkU X-Received: by 2002:a17:906:bcd5:: with SMTP id lw21mr27373161ejb.346.1623234608321; Wed, 09 Jun 2021 03:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623234608; cv=none; d=google.com; s=arc-20160816; b=IJgLHHXhHVF11u4GKTDxI9GiOlgzCvxv3dgcmljrBSkDHZ6K3i//qzENinOjIOm95u DXvmqJWU3gFpy/kpfJjBq1121gAz1EQi9Eas26eb/LZowSbnO4BEh26kDM6G17cudc5l pxqwQzkvKnugq/UFsBJGh0M45Or6I/ft8SKWwHWXSHWLVKbPQBxqOAnwOLt//hcjpsb/ 52loeu4M1sk4d7Ymbwlc5hEHloSojB8O5OK778WI+v57FID6c0b1qZrBP7lXE7nGpKyZ hCa50s8YdnAxFyQBHvIP4xDNerpP/TzWH2iXgGRAloi/NFwdbqwtrUbB0WNIxtNHxdDD 38qA== 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=ooMLMQkPzQEJUvL/wJf7aBuZXxgDHZegfP92uag8VSE=; b=nKGHM0wCqwKPdOiOxgHL8t8HN98ea7v8Aoo6V9bIqNpXnyaYw1TEYdp7jReWtIGg5T sC1kyuSvfVuhsNtQIanwQiTjjY+c9sDsppN5l4KRckjFbi3WRof9xYMx+LRjMF7Y6nrP 5Tu5RR2g3FQEFS017/BVoLTsBnJ/kGZYNlCQrjDOFkZBl9oOQmQSRvNrXaDBFVtpDEch KXtKmzFeI80xy2IsntrRJlgUevGOWkKbq5aY91sHcyhqwX82L4OLXW1gDwS6Yy+kJfdH 0n4kZrMSfl+jpmSr2wI7PntLYdFDYU8H/XporNHUB+9rwXuYr2CJsngGpCk3ajTamGih uPlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HoICLtUe; 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 5si2175000ejl.332.2021.06.09.03.29.45; Wed, 09 Jun 2021 03:30:08 -0700 (PDT) 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=HoICLtUe; 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 S237187AbhFHTAC (ORCPT + 99 others); Tue, 8 Jun 2021 15:00:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:48990 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234057AbhFHSxk (ORCPT ); Tue, 8 Jun 2021 14:53:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AF43A61494; Tue, 8 Jun 2021 18:40:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177639; bh=OXMgJZdyGVlDOsLY8gbihH51ZPYK7DN7QiWKhOqYGhc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HoICLtUeQprXlvgNVa3MjxseNIWWf/jTn100F7dd95SAYkzuyiX6Ogx8FG327qA6R lU28mEejNVCmvHdcqzkY3PT6iqiAZhSjygBlNUw3liMcw5mNyZdZ1C8IpdncDb77TB k2GenDKj9Zhvkr1v9IAmh/0cA1WW26c7t7PafVS4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Wei Yongjun , Alex Williamson , Sasha Levin Subject: [PATCH 5.10 012/137] samples: vfio-mdev: fix error handing in mdpy_fb_probe() Date: Tue, 8 Jun 2021 20:25:52 +0200 Message-Id: <20210608175942.798881844@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175942.377073879@linuxfoundation.org> References: <20210608175942.377073879@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: Wei Yongjun [ Upstream commit 752774ce7793a1f8baa55aae31f3b4caac49cbe4 ] Fix to return a negative error code from the framebuffer_alloc() error handling case instead of 0, also release regions in some error handing cases. Fixes: cacade1946a4 ("sample: vfio mdev display - guest driver") Reported-by: Hulk Robot Signed-off-by: Wei Yongjun Message-Id: <20210520133641.1421378-1-weiyongjun1@huawei.com> Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- samples/vfio-mdev/mdpy-fb.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c index 21dbf63d6e41..9ec93d90e8a5 100644 --- a/samples/vfio-mdev/mdpy-fb.c +++ b/samples/vfio-mdev/mdpy-fb.c @@ -117,22 +117,27 @@ 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); info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev); - if (!info) + if (!info) { + ret = -ENOMEM; goto err_release_regions; + } pci_set_drvdata(pdev, info); par = info->par; -- 2.30.2