Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1259422

[PATCH] video:fbdev:core:Calculate the size for colormap only after the validation of length for colormap.

From Shailendra Verma <shailendra.v@samung.com>
Newsgroups linux.kernel
Subject [PATCH] video:fbdev:core:Calculate the size for colormap only after the validation of length for colormap.
Date 2015-10-30 12:40 +0100
Message-ID <qpgci-5f8-33@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View 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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] video:fbdev:core:Calculate the size for colormap only after  the validation of length for colormap. Shailendra Verma <shailendra.v@samung.com> - 2015-10-30 12:40 +0100

csiph-web