diff mbox series

[v2,3/5] vfio: platform: simplify device removal

Message ID 20201124133139.3072124-4-uwe@kleine-koenig.org (mailing list archive)
State New, archived
Headers show
Series amba: minor fix and various cleanups | expand

Commit Message

Uwe Kleine-König Nov. 24, 2020, 1:31 p.m. UTC
From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

vfio_platform_remove_common() cannot return non-NULL in
vfio_amba_remove() as the latter is only called if vfio_amba_probe()
returned success.

Diagnosed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/vfio/platform/vfio_amba.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Eric Auger Dec. 2, 2020, 3:15 p.m. UTC | #1
Hi Uwe,

On 11/24/20 2:31 PM, Uwe Kleine-König wrote:
> From: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> 
> vfio_platform_remove_common() cannot return non-NULL in
> vfio_amba_remove() as the latter is only called if vfio_amba_probe()
> returned success.
> 
> Diagnosed-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Eric Auger <eric.auger@redhat.com>

Thanks

Eric
> ---
>  drivers/vfio/platform/vfio_amba.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c
> index 9636a2afaecd..7b3ebf1558e1 100644
> --- a/drivers/vfio/platform/vfio_amba.c
> +++ b/drivers/vfio/platform/vfio_amba.c
> @@ -73,16 +73,12 @@ static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id)
>  
>  static int vfio_amba_remove(struct amba_device *adev)
>  {
> -	struct vfio_platform_device *vdev;
> -
> -	vdev = vfio_platform_remove_common(&adev->dev);
> -	if (vdev) {
> -		kfree(vdev->name);
> -		kfree(vdev);
> -		return 0;
> -	}
> +	struct vfio_platform_device *vdev =
> +		vfio_platform_remove_common(&adev->dev);
>  
> -	return -EINVAL;
> +	kfree(vdev->name);
> +	kfree(vdev);
> +	return 0;
>  }
>  
>  static const struct amba_id pl330_ids[] = {
>
diff mbox series

Patch

diff --git a/drivers/vfio/platform/vfio_amba.c b/drivers/vfio/platform/vfio_amba.c
index 9636a2afaecd..7b3ebf1558e1 100644
--- a/drivers/vfio/platform/vfio_amba.c
+++ b/drivers/vfio/platform/vfio_amba.c
@@ -73,16 +73,12 @@  static int vfio_amba_probe(struct amba_device *adev, const struct amba_id *id)
 
 static int vfio_amba_remove(struct amba_device *adev)
 {
-	struct vfio_platform_device *vdev;
-
-	vdev = vfio_platform_remove_common(&adev->dev);
-	if (vdev) {
-		kfree(vdev->name);
-		kfree(vdev);
-		return 0;
-	}
+	struct vfio_platform_device *vdev =
+		vfio_platform_remove_common(&adev->dev);
 
-	return -EINVAL;
+	kfree(vdev->name);
+	kfree(vdev);
+	return 0;
 }
 
 static const struct amba_id pl330_ids[] = {