[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_410AFB702E25A27F689010E6A1DC308E7807@qq.com>
Date: Fri, 4 Mar 2022 16:17:41 +0800
From: xkernel.wang@...mail.com
To: nsaenz@...nel.org, gregkh@...uxfoundation.org
Cc: bcm-kernel-feedback-list@...adcom.com,
linux-rpi-kernel@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org,
linux-staging@...ts.linux.dev, linux-kernel@...r.kernel.org,
Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH] staging: mmal-vchiq: add a check for the return of vmalloc()
From: Xiaoke Wang <xkernel.wang@...mail.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@...mail.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);
--
Powered by blists - more mailing lists