linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arvind Yadav <arvind.yadav.cs@gmail.com>
To: benjamin.gaignard@linaro.org, vincent.abriou@st.com, airlied@linux.ie
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [v1] gpu: drm: sti: sti_vtg:- Handle return NULL error from devm_ioremap_nocache
Date: Wed, 21 Dec 2016 11:00:12 +0530	[thread overview]
Message-ID: <1482298212-4760-1-git-send-email-arvind.yadav.cs@gmail.com> (raw)

Here, If devm_ioremap_nocache will fail. It will return NULL.
Kernel can run into a NULL-pointer dereference. This error check
will avoid NULL pointer dereference.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 drivers/gpu/drm/sti/sti_vtg.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c
index a8882bd..c3d9c8a 100644
--- a/drivers/gpu/drm/sti/sti_vtg.c
+++ b/drivers/gpu/drm/sti/sti_vtg.c
@@ -429,6 +429,10 @@ static int vtg_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 	vtg->regs = devm_ioremap_nocache(dev, res->start, resource_size(res));
+	if (!vtg->regs) {
+		DRM_ERROR("failed to remap I/O memory\n");
+		return -ENOMEM;
+	}
 
 	np = of_parse_phandle(pdev->dev.of_node, "st,slave", 0);
 	if (np) {
-- 
1.7.9.5

             reply	other threads:[~2016-12-21  5:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21  5:30 Arvind Yadav [this message]
2017-01-04  9:29 ` [v1] gpu: drm: sti: sti_vtg:- Handle return NULL error from devm_ioremap_nocache Vincent ABRIOU

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=1482298212-4760-1-git-send-email-arvind.yadav.cs@gmail.com \
    --to=arvind.yadav.cs@gmail.com \
    --cc=airlied@linux.ie \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=vincent.abriou@st.com \
    /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;
as well as URLs for NNTP newsgroup(s).