[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <YxBqwp6rzR54RTZ3@kroah.com>
Date: Thu, 1 Sep 2022 10:18:10 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc: hdegoede@...hat.com, arnd@...db.de, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] virt: vbox: Add check for device_create_file
On Thu, Sep 01, 2022 at 03:45:21PM +0800, Jiasheng Jiang wrote:
> As device_create_file() can return error number,
> it should be better to check the return value and
> deal with the exception.
>
> Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
> drivers/virt/vboxguest/vboxguest_linux.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c
> index 4ccfd30c2a30..0fee8e6ee6e0 100644
> --- a/drivers/virt/vboxguest/vboxguest_linux.c
> +++ b/drivers/virt/vboxguest/vboxguest_linux.c
> @@ -390,8 +390,13 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id)
> }
>
> pci_set_drvdata(pci, gdev);
> - device_create_file(dev, &dev_attr_host_version);
> - device_create_file(dev, &dev_attr_host_features);
> +
> + ret = device_create_file(dev, &dev_attr_host_version);
> + if (ret)
> + goto err_unregister_misc_device_user;
> + ret = device_create_file(dev, &dev_attr_host_features);
> + if (ret)
> + goto err_unregister_misc_device_user;
This is also buggy, please always test your changes before sending them
out :(
Powered by blists - more mailing lists