diff mbox

switchtec: checking for NULL instead of IS_ERR()

Message ID 20170412083525.GF3250@mwanda (mailing list archive)
State New, archived
Delegated to: Bjorn Helgaas
Headers show

Commit Message

Dan Carpenter April 12, 2017, 8:35 a.m. UTC
stuser_create() uses error pointers, it never returns NULL.

Fixes: 74004262f329 ("MicroSemi Switchtec management interface driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Logan Gunthorpe April 12, 2017, 4:47 p.m. UTC | #1
Hi Dan,

Thanks for the fix. This is the exact same patch Christophe Jaillet sent
a couple of days ago so only one needs to be merged.

Logan

On 12/04/17 02:35 AM, Dan Carpenter wrote:
> stuser_create() uses error pointers, it never returns NULL.
> 
> Fixes: 74004262f329 ("MicroSemi Switchtec management interface driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
> index fcde98161d9a..cc6e085008fb 100644
> --- a/drivers/pci/switch/switchtec.c
> +++ b/drivers/pci/switch/switchtec.c
> @@ -608,7 +608,7 @@ static int switchtec_dev_open(struct inode *inode, struct file *filp)
>  	stdev = container_of(inode->i_cdev, struct switchtec_dev, cdev);
>  
>  	stuser = stuser_create(stdev);
> -	if (!stuser)
> +	if (IS_ERR(stuser))
>  		return PTR_ERR(stuser);
>  
>  	filp->private_data = stuser;
>
diff mbox

Patch

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index fcde98161d9a..cc6e085008fb 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -608,7 +608,7 @@  static int switchtec_dev_open(struct inode *inode, struct file *filp)
 	stdev = container_of(inode->i_cdev, struct switchtec_dev, cdev);
 
 	stuser = stuser_create(stdev);
-	if (!stuser)
+	if (IS_ERR(stuser))
 		return PTR_ERR(stuser);
 
 	filp->private_data = stuser;