All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] staging: mmal-vchiq: add a check for the return of vmalloc()
@ 2022-03-15 14:42 ` xkernel.wang
  0 siblings, 0 replies; 10+ messages in thread
From: xkernel.wang @ 2022-03-15 14:42 UTC (permalink / raw)
  To: gregkh, nsaenz
  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>
---
ChangeLog:
v1->v2  jump to the proper location and remove redundant instruction.
 drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c | 4 ++++
 1 file changed, 4 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..ff4b484 100644
--- a/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/staging/vc04_services/vchiq-mmal/mmal-vchiq.c
@@ -1909,6 +1909,10 @@ 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;
+		goto err_free;
+	}
 	instance->vchiq_instance = vchiq_instance;
 
 	mutex_init(&instance->context_map_lock);
-- 

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

end of thread, other threads:[~2022-03-16 14:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15 14:42 [PATCH v2] staging: mmal-vchiq: add a check for the return of vmalloc() xkernel.wang
2022-03-15 14:42 ` xkernel.wang
2022-03-15 15:27 ` Greg KH
2022-03-15 15:27   ` Greg KH
2022-03-15 15:53   ` Dan Carpenter
2022-03-15 15:53     ` Dan Carpenter
2022-03-15 16:23   ` Xiaoke Wang
2022-03-15 16:23     ` Xiaoke Wang
2022-03-16 14:08     ` gregkh
2022-03-16 14:08       ` gregkh

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.