All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
@ 2022-03-04  8:17 ` xkernel.wang
  0 siblings, 0 replies; 6+ messages in thread
From: xkernel.wang @ 2022-03-04  8:17 UTC (permalink / raw)
  To: nsaenz, gregkh
  Cc: bcm-kernel-feedback-list, linux-rpi-kernel, linux-arm-kernel,
	linux-staging, linux-kernel, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

vmalloc() is a memory allocation API which can return NULL when some
internal memory errors happen. So it is better to check the return
value of it to catch the error in time.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
index 76d3f03..1bbd301 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1909,6 +1909,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
 	mutex_init(&instance->vchiq_mutex);
 
 	instance->bulk_scratch = vmalloc(PAGE_SIZE);
+	if (!instance->bulk_scratch) {
+		err = -ENOMEM;
+		kfree(instance);
+		goto err_shutdown_vchiq;
+	}
 	instance->vchiq_instance = vchiq_instance;
 
 	mutex_init(&instance->context_map_lock);
-- 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
@ 2022-03-04  8:17 ` xkernel.wang
  0 siblings, 0 replies; 6+ messages in thread
From: xkernel.wang @ 2022-03-04  8:17 UTC (permalink / raw)
  To: nsaenz, gregkh
  Cc: bcm-kernel-feedback-list, linux-rpi-kernel, linux-arm-kernel,
	linux-staging, linux-kernel, Xiaoke Wang

From: Xiaoke Wang <xkernel.wang@foxmail.com>

vmalloc() is a memory allocation API which can return NULL when some
internal memory errors happen. So it is better to check the return
value of it to catch the error in time.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
index 76d3f03..1bbd301 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1909,6 +1909,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
 	mutex_init(&instance->vchiq_mutex);
 
 	instance->bulk_scratch = vmalloc(PAGE_SIZE);
+	if (!instance->bulk_scratch) {
+		err = -ENOMEM;
+		kfree(instance);
+		goto err_shutdown_vchiq;
+	}
 	instance->vchiq_instance = vchiq_instance;
 
 	mutex_init(&instance->context_map_lock);
-- 

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

* Re: [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
  2022-03-04  8:17 ` xkernel.wang
@ 2022-03-15 14:21   ` Greg KH
  -1 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2022-03-15 14:21 UTC (permalink / raw)
  To: xkernel.wang
  Cc: nsaenz, bcm-kernel-feedback-list, linux-rpi-kernel,
	linux-arm-kernel, linux-staging, linux-kernel

On Fri, Mar 04, 2022 at 04:17:41PM +0800, xkernel.wang@foxmail.com wrote:
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
> 
> vmalloc() is a memory allocation API which can return NULL when some
> internal memory errors happen. So it is better to check the return
> value of it to catch the error in time.
> 
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
> ---
>  drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> index 76d3f03..1bbd301 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> @@ -1909,6 +1909,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
>  	mutex_init(&instance->vchiq_mutex);
>  
>  	instance->bulk_scratch = vmalloc(PAGE_SIZE);
> +	if (!instance->bulk_scratch) {
> +		err = -ENOMEM;
> +		kfree(instance);

This is called in the error section, please just jump to the proper
location and then this line will not be needed.

thanks,

greg k-h

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

* Re: [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
@ 2022-03-15 14:21   ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2022-03-15 14:21 UTC (permalink / raw)
  To: xkernel.wang
  Cc: nsaenz, bcm-kernel-feedback-list, linux-rpi-kernel,
	linux-arm-kernel, linux-staging, linux-kernel

On Fri, Mar 04, 2022 at 04:17:41PM +0800, xkernel.wang@foxmail.com wrote:
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
> 
> vmalloc() is a memory allocation API which can return NULL when some
> internal memory errors happen. So it is better to check the return
> value of it to catch the error in time.
> 
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
> ---
>  drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> index 76d3f03..1bbd301 100644
> --- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> +++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
> @@ -1909,6 +1909,11 @@ int vchiq_mmal_init(struct vchiq_mmal_instance **out_instance)
>  	mutex_init(&instance->vchiq_mutex);
>  
>  	instance->bulk_scratch = vmalloc(PAGE_SIZE);
> +	if (!instance->bulk_scratch) {
> +		err = -ENOMEM;
> +		kfree(instance);

This is called in the error section, please just jump to the proper
location and then this line will not be needed.

thanks,

greg k-h

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
  2022-03-15 14:21   ` Greg KH
@ 2022-03-15 15:49     ` Dan Carpenter
  -1 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-03-15 15:49 UTC (permalink / raw)
  To: Greg KH, xkernel.wang
  Cc: nsaenz, bcm-kernel-feedback-list, linux-rpi-kernel,
	linux-arm-kernel, linux-staging, linux-kernel

On Tue, Mar 15, 2022 at 03:21:30PM +0100, Greg KH wrote:
> On Fri, Mar 04, 2022 at 04:17:41PM +0800, xkernel.wang@foxmail.com wrote:
> > From: Xiaoke Wang <xkernel.wang@foxmail.com>
> > 
> > vmalloc() is a memory allocation API which can return NULL when some
> > internal memory errors happen. So it is better to check the return
> > value of it to catch the error in time.
> > 
> > Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>

Unfortunately these patches are not making it to the
linux-staging@lists.linux.dev list.  They are on LKML but no one reads
LKML.

Here is the link to the staging archive.  Greg's email is there.  But
the first email is missing.
https://lore.kernel.org/linux-staging/YjCg6oQcNiGKEH3x@kroah.com/T/#u

regards,
dan carpenter


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

* Re: [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
@ 2022-03-15 15:49     ` Dan Carpenter
  0 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2022-03-15 15:49 UTC (permalink / raw)
  To: Greg KH, xkernel.wang
  Cc: nsaenz, bcm-kernel-feedback-list, linux-rpi-kernel,
	linux-arm-kernel, linux-staging, linux-kernel

On Tue, Mar 15, 2022 at 03:21:30PM +0100, Greg KH wrote:
> On Fri, Mar 04, 2022 at 04:17:41PM +0800, xkernel.wang@foxmail.com wrote:
> > From: Xiaoke Wang <xkernel.wang@foxmail.com>
> > 
> > vmalloc() is a memory allocation API which can return NULL when some
> > internal memory errors happen. So it is better to check the return
> > value of it to catch the error in time.
> > 
> > Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>

Unfortunately these patches are not making it to the
linux-staging@lists.linux.dev list.  They are on LKML but no one reads
LKML.

Here is the link to the staging archive.  Greg's email is there.  But
the first email is missing.
https://lore.kernel.org/linux-staging/YjCg6oQcNiGKEH3x@kroah.com/T/#u

regards,
dan carpenter


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-03-15 15:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-04  8:17 [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc() xkernel.wang
2022-03-04  8:17 ` xkernel.wang
2022-03-15 14:21 ` Greg KH
2022-03-15 14:21   ` Greg KH
2022-03-15 15:49   ` Dan Carpenter
2022-03-15 15:49     ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.