Skip to contentSkip to conversation

vhost: vdpa: remove unnecessary null check

PATCH In review Gustavo A. R. Silva 3 participants 3 messages Mar 30, 2020 – Mar 31, 2020

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

PATCH 1/1 vhost: vdpa: remove unnecessary null check

container_of is never null, so this null check is
unnecessary.

Addresses-Coverity-ID: 1492006 ("Logically dead code")

Fixes 20453a45fb06 ("vhost: introduce vDPA-based backend")
---
 drivers/vhost/vdpa.c | 2 --
 1 file changed, 2 deletions(-)
drivers/vhost/vdpa.c +0 -2
index 421f02a8530a..3d2cb811757a 100644
@@ -678,8 +678,6 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 	int nvqs, i, r, opened;
 
 	v = container_of(inode->i_cdev, struct vhost_vdpa, cdev);
-	if (!v)
-		return -ENODEV;
 
 	opened = atomic_cmpxchg(&v->opened, 0, 1);
 	if (opened)
Signature · 1 line
2.26.0
Acked-by on v1 1/1
#1 lore raw
Quoted 15 lines · Gustavo A. R. Silva

container_of is never null, so this null check is
unnecessary.

Addresses-Coverity-ID: 1492006 ("Logically dead code")

Fixes 20453a45fb06 ("vhost: introduce vDPA-based backend")
---
  drivers/vhost/vdpa.c | 2 --
  1 file changed, 2 deletions(-)
drivers/vhost/vdpa.c +0 -0
index 421f02a8530a..3d2cb811757a 100644

drivers/vhost/vdpa.c static int vhost_vdpa_open(struct inode *inode, struct file *filep) · line 683

Quoted 8 lines
drivers/vhost/vdpa.c +0 -2
@@ -678,8 +678,6 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
  	int nvqs, i, r, opened;
 
  	v = container_of(inode->i_cdev, struct vhost_vdpa, cdev);
-	if (!v)
-		return -ENODEV;
 
  	opened = atomic_cmpxchg(&v->opened, 0, 1);
  	if (opened)

Thanks

#2 lore raw
In reply to Gustavo A. R. Silva
Quoted 6 lines · Gustavo A. R. Silva

container_of is never null, so this null check is
unnecessary.

Addresses-Coverity-ID: 1492006 ("Logically dead code")

Fixes 20453a45fb06 ("vhost: introduce vDPA-based backend")

Yes weird. Was the point to test i_cdev? Tiwei?

Quoted 19 lines
---
 drivers/vhost/vdpa.c | 2 --
 1 file changed, 2 deletions(-)
drivers/vhost/vdpa.c +0 -2
index 421f02a8530a..3d2cb811757a 100644
@@ -678,8 +678,6 @@ static int vhost_vdpa_open(struct inode *inode, struct file *filep)
 	int nvqs, i, r, opened;
 
 	v = container_of(inode->i_cdev, struct vhost_vdpa, cdev);
-	if (!v)
-		return -ENODEV;
 
 	opened = atomic_cmpxchg(&v->opened, 0, 1);
 	if (opened)
Signature · 1 line
2.26.0