public inbox for v9fs@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] 9p/trans_usbg: Fix incorrect error check in usb9pfs_alloc_instance()
@ 2024-10-19  9:23 Yue Haibing
  2024-10-19 11:58 ` Christian Schoenebeck
  0 siblings, 1 reply; 2+ messages in thread
From: Yue Haibing @ 2024-10-19  9:23 UTC (permalink / raw)
  To: ericvh, lucho, asmadeus, linux_oss, m.grzeschik, yuehaibing,
	gregkh
  Cc: v9fs, linux-kernel

kzalloc() should use NULL check not a IS_ERR() check.

Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport")
Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
---
 net/9p/trans_usbg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c
index 975b76839dca..6b694f117aef 100644
--- a/net/9p/trans_usbg.c
+++ b/net/9p/trans_usbg.c
@@ -909,9 +909,9 @@ static struct usb_function_instance *usb9pfs_alloc_instance(void)
 	usb9pfs_opts->buflen = DEFAULT_BUFLEN;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (IS_ERR(dev)) {
+	if (!dev) {
 		kfree(usb9pfs_opts);
-		return ERR_CAST(dev);
+		return ERR_PTR(-ENOMEM);
 	}
 
 	usb9pfs_opts->dev = dev;
-- 
2.34.1


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

* Re: [PATCH] 9p/trans_usbg: Fix incorrect error check in usb9pfs_alloc_instance()
  2024-10-19  9:23 [PATCH] 9p/trans_usbg: Fix incorrect error check in usb9pfs_alloc_instance() Yue Haibing
@ 2024-10-19 11:58 ` Christian Schoenebeck
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Schoenebeck @ 2024-10-19 11:58 UTC (permalink / raw)
  To: ericvh, lucho, asmadeus, m.grzeschik, yuehaibing, gregkh,
	Yue Haibing
  Cc: v9fs, linux-kernel

On Saturday, October 19, 2024 11:23:02 AM CEST Yue Haibing wrote:
> kzalloc() should use NULL check not a IS_ERR() check.
> 
> Fixes: a3be076dc174 ("net/9p/usbg: Add new usb gadget function transport")
> Signed-off-by: Yue Haibing <yuehaibing@huawei.com>

Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>

> ---
>  net/9p/trans_usbg.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/9p/trans_usbg.c b/net/9p/trans_usbg.c
> index 975b76839dca..6b694f117aef 100644
> --- a/net/9p/trans_usbg.c
> +++ b/net/9p/trans_usbg.c
> @@ -909,9 +909,9 @@ static struct usb_function_instance *usb9pfs_alloc_instance(void)
>  	usb9pfs_opts->buflen = DEFAULT_BUFLEN;
>  
>  	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> -	if (IS_ERR(dev)) {
> +	if (!dev) {
>  		kfree(usb9pfs_opts);
> -		return ERR_CAST(dev);
> +		return ERR_PTR(-ENOMEM);
>  	}
>  
>  	usb9pfs_opts->dev = dev;
> 



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

end of thread, other threads:[~2024-10-19 12:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-19  9:23 [PATCH] 9p/trans_usbg: Fix incorrect error check in usb9pfs_alloc_instance() Yue Haibing
2024-10-19 11:58 ` Christian Schoenebeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox