Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752401AbbKIIHH (ORCPT ); Mon, 9 Nov 2015 03:07:07 -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 X-AuditID: cbfee61b-f79d56d0000048c5-33-56405425dd07 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1337 Lines: 40 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; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/