[dpdk-dev,v3] eal/linuxapp: fix return value check of mknod()

Message ID 1479365235-134903-1-git-send-email-wei.dai@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
checkpatch/checkpatch success coding style OK

Commit Message

Wei Dai Nov. 17, 2016, 6:47 a.m. UTC
  In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
The return value of mknod() is ret, not f got by fopen().
So the value of ret should be checked for mknod().

Fixes: f7f97c16048e ("pci: add option --create-uio-dev to run without hotplug")

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
v3:
* correct Fixes: line in git commit message body

v2:
* fix my local git setting and send same patch again to remove
  "From: Wei Dai <wei.dai@intel.com>" in git commit message body
  and make merging easier

 lib/librte_eal/linuxapp/eal/eal_pci_uio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Olivier Matz Dec. 6, 2016, 10:44 a.m. UTC | #1
Hi Wei,

On Thu, 17 Nov 2016 14:47:15 +0800, Wei Dai <wei.dai@intel.com> wrote:
> In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> The return value of mknod() is ret, not f got by fopen().
> So the value of ret should be checked for mknod().
> 
> Fixes: f7f97c16048e ("pci: add option --create-uio-dev to run without
> hotplug")
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>

Acked-by: Olivier Matz <olivier.matz@6wind.com>

Thanks
  
Thomas Monjalon Dec. 6, 2016, 11:01 a.m. UTC | #2
2016-12-06 11:44, Olivier Matz:
> Hi Wei,
> 
> On Thu, 17 Nov 2016 14:47:15 +0800, Wei Dai <wei.dai@intel.com> wrote:
> > In function pci_mknod_uio_dev() in lib/librte_eal/eal/eal_pci_uio.c,
> > The return value of mknod() is ret, not f got by fopen().
> > So the value of ret should be checked for mknod().
> > 
> > Fixes: f7f97c16048e ("pci: add option --create-uio-dev to run without
> > hotplug")

CC: stable@dpdk.org

> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> 
> Acked-by: Olivier Matz <olivier.matz@6wind.com>
> 
> Thanks

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
index 1786b75..3e4ffb5 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_uio.c
@@ -133,7 +133,7 @@  pci_mknod_uio_dev(const char *sysfs_uio_path, unsigned uio_num)
 	snprintf(filename, sizeof(filename), "/dev/uio%u", uio_num);
 	dev = makedev(major, minor);
 	ret = mknod(filename, S_IFCHR | S_IRUSR | S_IWUSR, dev);
-	if (f == NULL) {
+	if (ret != 0) {
 		RTE_LOG(ERR, EAL, "%s(): mknod() failed %s\n",
 			__func__, strerror(errno));
 		return -1;