Skip to contentSkip to conversation

vfio-mdev: fix some error codes in the sample code

PATCH In review Dan Carpenter 2 participants 2 messages Nov 24, 2016 – Nov 28, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfio-mdev: fix some error codes in the sample code

This is just sample code. We forget to set the error codes in a couple places.

samples/vfio-mdev/mtty.c +3 -1
index 6b633a4..40ed3c0 100644
@@ -1447,6 +1447,7 @@ static int __init mtty_dev_init(void)
 
 	if (IS_ERR(mtty_dev.vd_class)) {
 		pr_err("Error: failed to register mtty_dev class\n");
+		ret = PTR_ERR(mtty_dev.vd_class);
 		goto failed1;
 	}
 
@@ -1458,7 +1459,8 @@ static int __init mtty_dev_init(void)
 	if (ret)
 		goto failed2;
 
-	if (mdev_register_device(&mtty_dev.dev, &mdev_fops) != 0)
+	ret = mdev_register_device(&mtty_dev.dev, &mdev_fops);
+	if (ret)
 		goto failed3;
 
 	mutex_init(&mdev_list_lock);
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Dan Carpenter

This is just sample code. We forget to set the error codes in a couple places.

samples/vfio-mdev/mtty.c +1 -0
index 6b633a4..40ed3c0 100644
@@ -1447,6 +1447,7 @@ static int __init mtty_dev_init(void)
 
 	if (IS_ERR(mtty_dev.vd_class)) {
 		pr_err("Error: failed to register mtty_dev class\n");
+		ret = PTR_ERR(mtty_dev.vd_class);
 		goto failed1;
 	}
 

samples/vfio-mdev/mtty.c static int __init mtty_dev_init(void) · line 1466

Quoted 9 lines
samples/vfio-mdev/mtty.c +2 -1
@@ -1458,7 +1459,8 @@ static int __init mtty_dev_init(void)
 	if (ret)
 		goto failed2;
 
-	if (mdev_register_device(&mtty_dev.dev, &mdev_fops) != 0)
+	ret = mdev_register_device(&mtty_dev.dev, &mdev_fops);
+	if (ret)
 		goto failed3;
 
 	mutex_init(&mdev_list_lock);

Thanks for fixing this. Looks good to me.