kzalloc() is a memory allocation function which may return a NULL pointer.
Therefore, it is better to check the return value of kzalloc() to avoid potential
NULL-pointer dereference.
Signed-off-by: QintaoShen <unSimple1993@xxxxxxx>
---
drivers/md/bcache/request.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/md/bcache/request.c b/drivers/md/bcache/request.c
index fdd0194..232ffe3 100644
--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -1105,6 +1105,9 @@ static void detached_dev_do_request(struct bcache_device *d, struct bio *bio,
* which would call closure_get(&dc->disk.cl)
*/
ddip = kzalloc(sizeof(struct detached_dev_io_private), GFP_NOIO);
+ if (!ddpp)
+ return ;
+
ddip->d = d;
/* Count on the bcache device */
ddip->orig_bdev = orig_bdev;