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


Groups > linux.kernel > #1259421 > unrolled thread

[PATCH] video:fbdev:core:Allocate the memory for video mode after the validation of edid.

Started byShailendra Verma <shailendra.v@samung.com>
First post2015-10-30 12:40 +0100
Last post2015-10-30 12:40 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] video:fbdev:core:Allocate the memory for video mode after the  validation of edid. Shailendra Verma <shailendra.v@samung.com> - 2015-10-30 12:40 +0100

#1259421 — [PATCH] video:fbdev:core:Allocate the memory for video mode after the validation of edid.

FromShailendra Verma <shailendra.v@samung.com>
Date2015-10-30 12:40 +0100
Subject[PATCH] video:fbdev:core:Allocate the memory for video mode after the validation of edid.
Message-ID<qpgci-5f8-31@gated-at.bofh.it>
From: Shailendra Verma <shailendra.v@samsung.com>

In this function "fb_create_modedb" the memory for video mode is getting
allocated before the edid validation.If the validation of edid fails
then we are freeing the allocated memory for the video mode and returning.
So moving the memory allocation part after the edid validation.There is no
need to allocate the memory before edid validation check and freeing if
validation gets failed.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/video/fbdev/core/fbmon.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c
index 47c3191..476a5fd 100644
--- a/drivers/video/fbdev/core/fbmon.c
+++ b/drivers/video/fbdev/core/fbmon.c
@@ -620,16 +620,16 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize,
 	int num = 0, i, first = 1;
 	int ver, rev;
 
-	mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL);
-	if (mode == NULL)
-		return NULL;
-
 	if (edid == NULL || !edid_checksum(edid) ||
 	    !edid_check_header(edid)) {
-		kfree(mode);
 		return NULL;
 	}
 
+	mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL);
+	if (mode == NULL)
+		return NULL;
+
+
 	ver = edid[EDID_STRUCT_VERSION];
 	rev = edid[EDID_STRUCT_REVISION];
 
-- 
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/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web