From: Shailendra Verma <shailendra.v@samung.com>
To: Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
Tomi Valkeinen <tomi.valkeinen@ti.com>,
linux-fbdev@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, vidushi.koul@samsung.com,
shailendra.v@samsung.com
Subject: [PATCH] video:fbdev:core:Calculate the size for colormap only after the validation of length for col
Date: Mon, 09 Nov 2015 08:18:13 +0000 [thread overview]
Message-ID: <1447056373-28633-1-git-send-email-shailendra.v@samung.com> (raw)
From: Shailendra Verma <shailendra.v@samsung.com>
While allocating the memory for color map, the memory size for colors
is being calculated before the validation of length for color map.
Moved the size calculation part after the validation of color map length.
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
drivers/video/fbdev/core/fbcmap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
index f89245b..45ad567 100644
--- a/drivers/video/fbdev/core/fbcmap.c
+++ b/drivers/video/fbdev/core/fbcmap.c
@@ -91,7 +91,7 @@ static const struct fb_cmap default_16_colors = {
int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
{
- int size = len * sizeof(u16);
+ int size;
int ret = -ENOMEM;
if (cmap->len != len) {
@@ -99,6 +99,7 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
if (!len)
return 0;
+ size = len * sizeof(u16);
cmap->red = kmalloc(size, flags);
if (!cmap->red)
goto fail;
--
1.9.1
next reply other threads:[~2015-11-09 8:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-09 8:18 Shailendra Verma [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-10-30 11:48 [PATCH] video:fbdev:core:Calculate the size for colormap only after the validation of length for col Shailendra Verma
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=1447056373-28633-1-git-send-email-shailendra.v@samung.com \
--to=shailendra.v@samung.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=plagnioj@jcrosoft.com \
--cc=shailendra.v@samsung.com \
--cc=tomi.valkeinen@ti.com \
--cc=vidushi.koul@samsung.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).