From patchwork Mon Nov 9 08:06:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shailendra Verma X-Patchwork-Id: 7581661 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 361659F2F7 for ; Mon, 9 Nov 2015 08:07:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 63B7D20607 for ; Mon, 9 Nov 2015 08:07:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 63DC5205C2 for ; Mon, 9 Nov 2015 08:07:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751468AbbKIIHE (ORCPT ); Mon, 9 Nov 2015 03:07:04 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:54444 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751037AbbKIIHD (ORCPT ); Mon, 9 Nov 2015 03:07:03 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NXJ018RXFVONBA0@mailout4.samsung.com>; Mon, 09 Nov 2015 17:07:01 +0900 (KST) X-AuditID: cbfee61b-f79d56d0000048c5-33-56405425dd07 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 53.12.18629.52450465; Mon, 9 Nov 2015 17:07:01 +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 <0NXJ000VWFUEO930@mmp1.samsung.com>; Mon, 09 Nov 2015 17:07:01 +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:Calculate the size for colormap only after the validation of length for colormap. Date: Mon, 09 Nov 2015 13:36:13 +0530 Message-id: <1447056373-28633-1-git-send-email-shailendra.v@samung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDJMWRmVeSWpSXmKPExsVy+t9jAV3VEIcwg9uzxC2aF69nszjR94HV 4vKuOWwW6x6+YLJY9O0Vs8X6+bfYLP5evMTmwO7x6sIdFo/9c9ewe/RtWcXocfzGdiaPz5vk AlijuGxSUnMyy1KL9O0SuDJezLvFXvCco2LDgqWsDYyT2LsYOTkkBEwk2r/uYYKwxSQu3FvP BmILCSxllFj7qbyLkQvIfs0o0XD2FlADBwebgIHEplsBIHERgW2MEpdPnWQBaWAWCJN4MLkR bJCwQKlE3+p2sHoWAVWJvoURIGFeAXeJZd/PsYGEJQQUJOZMspnAyL2AkWEVo0RqQXJBcVJ6 rlFearlecWJucWleul5yfu4mRnCYPJPewXh4l/shRgEORiUeXobp9mFCrIllxZW5hxglOJiV RHgPezuECfGmJFZWpRblxxeV5qQWH2KU5mBREufV9zQKExJITyxJzU5NLUgtgskycXBKNTB6 nrgueP1uwGPx2bfcBWPOPtJXlU3et1KN+2z4q/lhixNCKjQCv+/wjrd49OiN/6fKz12P9zck fvJm3SM6+0/MPrZ5bHskD+3jSmW5c2ER++OE/Q9EL+7iO6/grx9w1K//ewjXlsI7aj7z7rvU Wsk/7LyQHLl0vkXnP+mYM19sXe3Kp8dHiQgosRRnJBpqMRcVJwIAMcoK0Q8CAAA= 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 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;