From patchwork Fri Oct 30 11:37:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shailendra Verma X-Patchwork-Id: 7526481 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BBD619F37F for ; Fri, 30 Oct 2015 11:39:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED836207DC for ; Fri, 30 Oct 2015 11:39:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C5BD6207D4 for ; Fri, 30 Oct 2015 11:39:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030907AbbJ3Lj1 (ORCPT ); Fri, 30 Oct 2015 07:39:27 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:55551 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030759AbbJ3Lj0 (ORCPT ); Fri, 30 Oct 2015 07:39:26 -0400 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX102IMY70ZI960@mailout1.samsung.com>; Fri, 30 Oct 2015 20:39:08 +0900 (KST) X-AuditID: cbfee61b-f79d56d0000048c5-bb-563356dc51bc Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id BA.72.18629.CD653365; Fri, 30 Oct 2015 20:39:08 +0900 (KST) Received: from srin.p4 ([107.108.168.37]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NX1005WU6Z67A70@mmp1.samsung.com>; Fri, 30 Oct 2015 20:39:08 +0900 (KST) From: Shailendra Verma To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen , linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, vidushi.koul@samsung.com Subject: [PATCH] video:fbdev:core:Allocate the memory for video mode after the validation of edid. Date: Fri, 30 Oct 2015 17:07:53 +0530 Message-id: <1446205073-23830-1-git-send-email-shailendra.v@samung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHJMWRmVeSWpSXmKPExsVy+t9jAd07YcZhBn8WKVqc6PvAanF51xw2 i3UPXzBZrJ9/i83i78VLbA6sHq8u3GHx6NuyitHj+I3tTB6fN8kFsERx2aSk5mSWpRbp2yVw Zfx7m1fwnqviyJGPbA2Mnzm6GDk5JARMJO68vc0MYYtJXLi3nq2LkYtDSGApo8ST9d+hnNeM EjN7t7B3MXJwsAkYSGy6FQASFxFoZpTY3tXBCNLNLGAlMen/bFYQW1ggReLTmelgU1kEVCV6 Lq1jArF5Bdwlll9bDTZHQkBBYs4kmwmM3AsYGVYxSqQWJBcUJ6XnGuWllusVJ+YWl+al6yXn 525iBIfCM+kdjId3uR9iFOBgVOLhDUg2ChNiTSwrrsw9xCjBwawkwtvjZBwmxJuSWFmVWpQf X1Sak1p8iFGag0VJnFffE6haID2xJDU7NbUgtQgmy8TBKdXAOGNZ1KpZl8NtJI7eX3bh5IFu 9luJZ2wuC4b6/ZjhxLtsR+TZme0HZ2+0Eb0Ut7xo1o+Nl4pF3mzJ+KId9PvNgin+89bP5zVi 5F+6u5vtXmZ8zJlitlzpXTN5Vtelm6Z+KDui+G2Z5LYybrf8WWmbHjzM+LvqTVZcpMjXnlA7 z7q4Ha9fsk7/4KTEUpyRaKjFXFScCAA8bjD+AQIAAA== Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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];