From: Julia Lawall Date: Wed, 23 Dec 2015 13:58:01 +0100 (CET) Subject: [Intel-wired-lan] [PATCH] igb: fix compare_const_fl.cocci warnings In-Reply-To: References: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: intel-wired-lan@osuosl.org List-ID: Actully, there is a more serious problem here, that there are a lot of potential dereferences of invalid pointers, via calls like: dev_err(&adapter->pdev->dev, "map to unbound device!\n") julia On Wed, 23 Dec 2015, Julia Lawall wrote: > Kernel code typically uses == NULL. > > Generated by: scripts/coccinelle/misc/compare_const_fl.cocci > > CC: Gangfeng Huang > Signed-off-by: Fengguang Wu > Signed-off-by: Julia Lawall > > --- > > Alternatively, consider using !adapter. > > igb_cdev.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > --- a/drivers/net/ethernet/intel/igb/igb_cdev.c > +++ b/drivers/net/ethernet/intel/igb/igb_cdev.c > @@ -92,7 +92,7 @@ static int igb_bind(struct file *file, v > > adapter = (struct igb_adapter *)file->private_data; > > - if (NULL == adapter) > + if (adapter == NULL) > return -ENOENT; > > mmap_size = pci_resource_len(adapter->pdev, 0); > @@ -119,7 +119,7 @@ static long igb_mapring(struct file *fil > return -EINVAL; > > adapter = file->private_data; > - if (NULL == adapter) { > + if (adapter == NULL) { > dev_err(&adapter->pdev->dev, "map to unbound device!\n"); > return -ENOENT; > } > @@ -182,7 +182,7 @@ static long igb_mapbuf(struct file *file > return -EINVAL; > > adapter = file->private_data; > - if (NULL == adapter) { > + if (adapter == NULL) { > dev_err(&adapter->pdev->dev, "map to unbound device!\n"); > return -ENOENT; > } > @@ -246,7 +246,7 @@ static long igb_unmapring(struct file *f > return -EINVAL; > > adapter = file->private_data; > - if (NULL == adapter) { > + if (adapter == NULL) { > dev_err(&adapter->pdev->dev, "map to unbound device!\n"); > return -ENOENT; > } > @@ -310,7 +310,7 @@ static long igb_unmapbuf(struct file *fi > return -EFAULT; > > adapter = file->private_data; > - if (NULL == adapter) { > + if (adapter == NULL) { > dev_err(&adapter->pdev->dev, "map to unbound device!\n"); > return -ENOENT; > } > @@ -398,7 +398,7 @@ static int igb_close_file(struct inode * > { > struct igb_adapter *adapter = file->private_data; > > - if (NULL == adapter) > + if (adapter == NULL) > return 0; > > mutex_lock(&adapter->cdev_mutex); > @@ -434,7 +434,7 @@ static int igb_mmap(struct file *file, s > dma_addr_t pgoff = vma->vm_pgoff; > dma_addr_t physaddr; > > - if (NULL == adapter) > + if (adapter == NULL) > return -ENODEV; > > if (pgoff == 0) >