From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shailendra Verma Date: Mon, 09 Nov 2015 08:15:24 +0000 Subject: [PATCH] video:fbdev:core:Allocate the memory for video mode after the validation of edid. Message-Id: <1447056204-28445-1-git-send-email-shailendra.v@samung.com> List-Id: References: <1446205073-23830-1-git-send-email-shailendra.v@samung.com> In-Reply-To: <1446205073-23830-1-git-send-email-shailendra.v@samung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org, Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, vidushi.koul@samsung.com From: Shailendra Verma 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 --- 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