Skip to contentSkip to conversation

vfio/pds: fix return value in pds_vfio_get_lm_file()

PATCH Applied Yang Yingliang 3 participants 3 messages Aug 19, 2023 – Aug 21, 2023

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

PATCH 1/1 vfio/pds: fix return value in pds_vfio_get_lm_file()

anon_inode_getfile() never returns NULL pointer, it will return ERR_PTR() when it fails, so replace the check with IS_ERR().

Fixes bb500dbe2ac6 ("vfio/pds: Add VFIO live migration support")
---
 drivers/vfio/pci/pds/lm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/pds/lm.c +1 -1
index aec75574cab3..79fe2e66bb49 100644
@@ -31,7 +31,7 @@ pds_vfio_get_lm_file(const struct file_operations *fops, int flags, u64 size)
 	/* Create file */
 	lm_file->filep =
 		anon_inode_getfile("pds_vfio_lm", fops, lm_file, flags);
-	if (!lm_file->filep)
+	if (IS_ERR(lm_file->filep))
 		goto out_free_file;
 
 	stream_open(lm_file->filep->f_inode, lm_file->filep);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Yang Yingliang

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

anon_inode_getfile() never returns NULL pointer, it will return ERR_PTR() when it fails, so replace the check with IS_ERR().

Fixes bb500dbe2ac6 ("vfio/pds: Add VFIO live migration support")
---
  drivers/vfio/pci/pds/lm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/pds/lm.c +0 -0
index aec75574cab3..79fe2e66bb49 100644

drivers/vfio/pci/pds/lm.c pds_vfio_get_lm_file(const struct file_operations *fops, int flags, u64 size) · line 35

Quoted 6 lines
drivers/vfio/pci/pds/lm.c +1 -1
@@ -31,7 +31,7 @@ pds_vfio_get_lm_file(const struct file_operations *fops, int flags, u64 size)
         /* Create file */
         lm_file->filep =
                 anon_inode_getfile("pds_vfio_lm", fops, lm_file, flags);
-       if (!lm_file->filep)
+       if (IS_ERR(lm_file->filep))
                 goto out_free_file;

LGTM! Thanks for fixing this.

Quoted 5 lines
drivers/vfio/pci/pds/lm.c +0 -1
         stream_open(lm_file->filep->f_inode, lm_file->filep);
--

2.25.1

#2 lore raw
In reply to Yang Yingliang
Quoted 14 lines · On Sat, 19 Aug 2023 10:37:16 +0800 Yang Yingliang <[email protected]>…

anon_inode_getfile() never returns NULL pointer, it will return ERR_PTR() when it fails, so replace the check with IS_ERR().

Fixes bb500dbe2ac6 ("vfio/pds: Add VFIO live migration support")
---
 drivers/vfio/pci/pds/lm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/vfio/pci/pds/lm.c +0 -0
index aec75574cab3..79fe2e66bb49 100644

drivers/vfio/pci/pds/lm.c pds_vfio_get_lm_file(const struct file_operations *fops, int flags, u64 size) · line 37

Quoted 8 lines
drivers/vfio/pci/pds/lm.c +1 -1
@@ -31,7 +31,7 @@ pds_vfio_get_lm_file(const struct file_operations *fops, int flags, u64 size)
 	/* Create file */
 	lm_file->filep =
 		anon_inode_getfile("pds_vfio_lm", fops, lm_file, flags);
-	if (!lm_file->filep)
+	if (IS_ERR(lm_file->filep))
 		goto out_free_file;
 
 	stream_open(lm_file->filep->f_inode, lm_file->filep);

Applied to vfio next branch for v6.6. Thanks,

Alex