linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] switchtec: Fix an error handling
@ 2017-04-11  4:32 Christophe JAILLET
  2017-04-11  4:36 ` Logan Gunthorpe
  2017-04-12 17:27 ` Bjorn Helgaas
  0 siblings, 2 replies; 4+ messages in thread
From: Christophe JAILLET @ 2017-04-11  4:32 UTC (permalink / raw)
  To: kurt.schwemmer, stephen.bates, logang, bhelgaas
  Cc: linux-pci, linux-kernel, kernel-janitors, Christophe JAILLET

'stuser_create' returns an error pointer in case of error, not NULL.
So test its return value with IS_ERR.

Fixes: 74004262f329 ("MicroSemi Switchtec management interface driver")

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/pci/switch/switchtec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] switchtec: Fix an error handling
  2017-04-11  4:32 [PATCH] switchtec: Fix an error handling Christophe JAILLET
@ 2017-04-11  4:36 ` Logan Gunthorpe
  2017-04-12 17:27 ` Bjorn Helgaas
  1 sibling, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2017-04-11  4:36 UTC (permalink / raw)
  To: Christophe JAILLET, kurt.schwemmer, stephen.bates, bhelgaas
  Cc: linux-pci, linux-kernel, kernel-janitors

Nice catch. Thanks.

Reviewed-by: Logan Gunthorpe <logang@deltatee.com>

Logan

On 10/04/17 10:32 PM, Christophe JAILLET wrote:
> 'stuser_create' returns an error pointer in case of error, not NULL.
> So test its return value with IS_ERR.
> 
> Fixes: 74004262f329 ("MicroSemi Switchtec management interface driver")
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/pci/switch/switchtec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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;
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] switchtec: Fix an error handling
  2017-04-11  4:32 [PATCH] switchtec: Fix an error handling Christophe JAILLET
  2017-04-11  4:36 ` Logan Gunthorpe
@ 2017-04-12 17:27 ` Bjorn Helgaas
  2017-04-12 17:28   ` Logan Gunthorpe
  1 sibling, 1 reply; 4+ messages in thread
From: Bjorn Helgaas @ 2017-04-12 17:27 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: kurt.schwemmer, stephen.bates, logang, bhelgaas, linux-pci,
	linux-kernel, kernel-janitors

On Tue, Apr 11, 2017 at 06:32:04AM +0200, Christophe JAILLET wrote:
> 'stuser_create' returns an error pointer in case of error, not NULL.
> So test its return value with IS_ERR.
> 
> Fixes: 74004262f329 ("MicroSemi Switchtec management interface driver")
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Since this hasn't been merged to Linus' tree yet, I folded the fix
into the original commit on pci/switchtec and added attribution to
Christophe.

> ---
>  drivers/pci/switch/switchtec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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;
> -- 
> 2.11.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] switchtec: Fix an error handling
  2017-04-12 17:27 ` Bjorn Helgaas
@ 2017-04-12 17:28   ` Logan Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Logan Gunthorpe @ 2017-04-12 17:28 UTC (permalink / raw)
  To: Bjorn Helgaas, Christophe JAILLET
  Cc: kurt.schwemmer, stephen.bates, bhelgaas, linux-pci, linux-kernel,
	kernel-janitors



On 12/04/17 11:27 AM, Bjorn Helgaas wrote:
> On Tue, Apr 11, 2017 at 06:32:04AM +0200, Christophe JAILLET wrote:
>> 'stuser_create' returns an error pointer in case of error, not NULL.
>> So test its return value with IS_ERR.
>>
>> Fixes: 74004262f329 ("MicroSemi Switchtec management interface driver")
>>
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> Since this hasn't been merged to Linus' tree yet, I folded the fix
> into the original commit on pci/switchtec and added attribution to
> Christophe.

Thanks Bjorn.

Logan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-04-12 17:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11  4:32 [PATCH] switchtec: Fix an error handling Christophe JAILLET
2017-04-11  4:36 ` Logan Gunthorpe
2017-04-12 17:27 ` Bjorn Helgaas
2017-04-12 17:28   ` Logan Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).