From patchwork Fri Oct 30 11:36:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shailendra Verma X-Patchwork-Id: 7526441 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 52B1C9F37F for ; Fri, 30 Oct 2015 11:37:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A621206EF for ; Fri, 30 Oct 2015 11:37:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 602B12053C for ; Fri, 30 Oct 2015 11:37:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030770AbbJ3Lhc (ORCPT ); Fri, 30 Oct 2015 07:37:32 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:45240 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030738AbbJ3Lhb (ORCPT ); Fri, 30 Oct 2015 07:37:31 -0400 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NX1027CM6YADE90@mailout3.samsung.com>; Fri, 30 Oct 2015 20:37:29 +0900 (KST) X-AuditID: cbfee61b-f79d56d0000048c5-32-56335679c4bd Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 36.52.18629.97653365; Fri, 30 Oct 2015 20:37:29 +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 <0NX10072R6WZ6Z50@mmp1.samsung.com>; Fri, 30 Oct 2015 20:37:29 +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:Calculate the size for colormap only after the validation of length for colormap. Date: Fri, 30 Oct 2015 17:06:34 +0530 Message-id: <1446204994-23755-1-git-send-email-shailendra.v@samung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLJMWRmVeSWpSXmKPExsVy+t9jAd3KMOMwgyvTJSxO9H1gtbi8aw6b xbqHL5gs1s+/xWbx9+IlNgdWj1cX7rB49G1Zxehx/MZ2Jo/Pm+QCWKK4bFJSczLLUov07RK4 Ml7Mu8Ve8JyjYsOCpawNjJPYuxg5OSQETCQ23vjHBGGLSVy4t56ti5GLQ0hgKaNEw7/XUM5r Rok5re9Yuxg5ONgEDCQ23QoAiYsINDNKbO/qYATpZhawkpj0fzYriC0sUCrRt7qdHaSeRUBV 4vHpABCTV8Bd4vIpBxBTQkBBYs4kmwmM3AsYGVYxSqQWJBcUJ6XnGuWllusVJ+YWl+al6yXn 525iBAfCM+kdjId3uR9iFOBgVOLhDUg2ChNiTSwrrsw9xCjBwawkwtvjZBwmxJuSWFmVWpQf X1Sak1p8iFGag0VJnFffE6haID2xJDU7NbUgtQgmy8TBKdXAaBGfxucqu2Lmi18iia/jWJ0c bB7eert42aW2AF/hJ1Mbcsq2SSqfEDLSW9bJqrZed1Wk3/6qfafrVfg1fUw9b/v/2cIyKfud RPmLNP2w/WLN04ovGr1zSj34Njzog+H38/vWulVZL3C+3BwXlKRpceReeITQPAGZOiMtf/bT Dzlu7P6Xm35KiaU4I9FQi7moOBEAeXCOAQACAAA= 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 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 --- 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;