All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Wei Yongjun <weiyongjun1@huawei.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>,
	"Kirti Wankhede" <kwankhede@nvidia.com>,
	Dan Carpenter <dan.carpenter@oracle.com>, <kvm@vger.kernel.org>,
	<kernel-janitors@vger.kernel.org>, Hulk Robot <hulkci@huawei.com>
Subject: Re: [PATCH -next v2] samples: vfio-mdev: fix error handing in mdpy_fb_probe()
Date: Mon, 24 May 2021 13:49:38 -0600	[thread overview]
Message-ID: <20210524134938.0d736615@x1.home.shazbot.org> (raw)
In-Reply-To: <20210520133641.1421378-1-weiyongjun1@huawei.com>

On Thu, 20 May 2021 13:36:41 +0000
Wei Yongjun <weiyongjun1@huawei.com> wrote:

> 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 <hulkci@huawei.com>
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
> v1 -> v2: add missing regions release.
> ---
>  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;
>  
> 

Thanks for adding the extra error cases.  Applied to vfio for-linus
branch for v5.13.  Thanks,

Alex


  reply	other threads:[~2021-05-24 19:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 13:36 [PATCH -next v2] samples: vfio-mdev: fix error handing in mdpy_fb_probe() Wei Yongjun
2021-05-24 19:49 ` Alex Williamson [this message]
2021-05-25 19:02   ` Christophe JAILLET

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210524134938.0d736615@x1.home.shazbot.org \
    --to=alex.williamson@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=hulkci@huawei.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.