From patchwork Mon Nov 9 08:04:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shailendra Verma X-Patchwork-Id: 7581641 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 904FE9F2F7 for ; Mon, 9 Nov 2015 08:05:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ABA84205C2 for ; Mon, 9 Nov 2015 08:05:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 93CA020394 for ; Mon, 9 Nov 2015 08:05:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001AbbKIIFo (ORCPT ); Mon, 9 Nov 2015 03:05:44 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:49161 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751706AbbKIIFo (ORCPT ); Mon, 9 Nov 2015 03:05:44 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NXJ01KPXFTCQFC0@mailout2.samsung.com>; Mon, 09 Nov 2015 17:05:42 +0900 (KST) X-AuditID: cbfee61a-f79a06d000005c6f-2c-564053d64e9d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 9F.84.23663.6D350465; Mon, 9 Nov 2015 17:05:42 +0900 (KST) Received: from srin.p4 ([107.108.168.37]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NXJ006VMFS1G170@mmp2.samsung.com>; Mon, 09 Nov 2015 17:05:42 +0900 (KST) From: Shailendra Verma 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, shailendra.v@samsung.com Subject: [PATCH] video:fbdev:core:Allocate the memory for video mode after the validation of edid. Date: Mon, 09 Nov 2015 13:34:48 +0530 Message-id: <1447056288-28543-1-git-send-email-shailendra.v@samung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t9jQd1rwQ5hBivvqFk0L17PZnGi7wOr xeVdc9gs1j18wWSx6NsrZov182+xWfy9eInNgd3j1YU7LB77565h9+jbsorR4/iN7UwenzfJ BbBGcdmkpOZklqUW6dslcGX8e5tX8J6r4siRj2wNjJ85uhg5OSQETCQ2/HvPDmGLSVy4t56t i5GLQ0hgFqNEz6YVLBDOa0aJeWtvAzkcHGwCBhKbbgWAxEUEtjFKXD51kgWkm1kgTOLB5EYm EFtYIEXi05npzCA2i4CqxO27U8FsXgF3iZ+LJzCBzJEQUJCYM8lmAiP3AkaGVYwSqQXJBcVJ 6bmGeanlesWJucWleel6yfm5mxjBgfJMagfjwV3uhxgFOBiVeHgZptuHCbEmlhVX5h5ilOBg VhLhPeztECbEm5JYWZValB9fVJqTWnyIUZqDRUmcV9/TKExIID2xJDU7NbUgtQgmy8TBKdXA qPfT7uMaaw8G77W+95fJTmW0NK6ROvQtocrtfv1EKyWlhu/dS+Z7pO4RvzLBouTeyk8ldb/P daSfaa1LUEr6ee3jlf0zjFhL49J+7hGRaX6neF/sxpGEbnXF5carbRv+K0QdE+nz/n73L0+t 9YvIDC2G1cuaty3LP3ClRd4zfndx2b8fOZcalFiKMxINtZiLihMBMP3FoxACAAA= 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.2 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];