mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: QintaoShen <unSimple1993@163.com>
To: sean@poorly.run
Cc: quic_abhinavk@quicinc.com, robdclark@gmail.com,
	linux-kernel@vger.kernel.org, QintaoShen <unSimple1993@163.com>
Subject: [PATCH v1] drm/msm: Check for NULL return of kzalloc()
Date: Thu, 24 Mar 2022 16:55:50 +0800	[thread overview]
Message-ID: <1648112150-6515-1-git-send-email-unSimple1993@163.com> (raw)

The allocation of kzalloc() may return NULL, which would bring a NULL
pointer dereference bug.

To avoid this confusion, it is better to check the return value of kzalloc().

Signed-off-by: QintaoShen <unSimple1993@163.com>
---
 drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c
index 5d2ff67..d017deb 100644
--- a/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c
+++ b/drivers/gpu/drm/msm/disp/msm_disp_snapshot_util.c
@@ -176,6 +176,8 @@ void msm_disp_snapshot_add_block(struct msm_disp_state *disp_state, u32 len,
 	va_list va;
 
 	new_blk = kzalloc(sizeof(struct msm_disp_state_block), GFP_KERNEL);
+	if (!new_blk)
+		return ;
 
 	va_start(va, fmt);
 
-- 
2.7.4


                 reply	other threads:[~2022-03-24  8:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1648112150-6515-1-git-send-email-unSimple1993@163.com \
    --to=unsimple1993@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_abhinavk@quicinc.com \
    --cc=robdclark@gmail.com \
    --cc=sean@poorly.run \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®