From patchwork Thu Feb 12 15:47:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 5820481 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 025AFBF440 for ; Thu, 12 Feb 2015 15:47:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C9D5C20225 for ; Thu, 12 Feb 2015 15:47:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DAEFC2021B for ; Thu, 12 Feb 2015 15:47:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755299AbbBLPrt (ORCPT ); Thu, 12 Feb 2015 10:47:49 -0500 Received: from mail-pd0-f170.google.com ([209.85.192.170]:36728 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753412AbbBLPrs (ORCPT ); Thu, 12 Feb 2015 10:47:48 -0500 Received: by pdjp10 with SMTP id p10so12766786pdj.3; Thu, 12 Feb 2015 07:47:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=y4fBEpaQkmp9Y3pQDXPnBU8O1h5vM1GrPLqP6xtEZsc=; b=dr5kUy8wPFkU6xuadyAyo2bmTKeqzUT2jn/bKbkiP2D73ATYvgNM1VBo+Ud1MTuccP jCQfTvJqVH7Rv8XZjpGqlcaoy0SlbwMaCIqGy2sgYrMJbamLkpSpglyd/eoVn13tDOz2 fX2qt7Z25qeFr4+zABantVbPkAPHJrx8pqZHaqjrXE8gUEVw5CYaTGYxZtSGV02EqLaf pDbl2U5nzmTRfQ8TB73oPQX+3lqRJzfUb/awzm89wjW3LKzrjPwYIP8Ij+s7KcwXFtfL cxOzvo4n0YKqeoOxVtDKNTW5WEZQgkFqWUAR5c/iZEAG+8FeSPpzt5j+86vH0xtWrB53 WUbw== X-Received: by 10.68.178.100 with SMTP id cx4mr7543480pbc.158.1423756068214; Thu, 12 Feb 2015 07:47:48 -0800 (PST) Received: from localhost.localdomain ([122.169.149.117]) by mx.google.com with ESMTPSA id ep2sm4091147pbc.78.2015.02.12.07.47.45 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Feb 2015 07:47:47 -0800 (PST) From: Sudip Mukherjee To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Sudip Mukherjee , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] video: fbdev: fix possible null dereference Date: Thu, 12 Feb 2015 21:17:36 +0530 Message-Id: <1423756056-15108-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 we were dereferencing edid first and the NULL check was after accessing that. now we are using edid only if we know that it is not NULL. Signed-off-by: Sudip Mukherjee --- drivers/video/fbdev/core/fbmon.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 9533859..868facd 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c @@ -624,9 +624,6 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, int num = 0, i, first = 1; int ver, rev; - ver = edid[EDID_STRUCT_VERSION]; - rev = edid[EDID_STRUCT_REVISION]; - mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL); if (mode == NULL) return NULL; @@ -637,6 +634,9 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, return NULL; } + ver = edid[EDID_STRUCT_VERSION]; + rev = edid[EDID_STRUCT_REVISION]; + *dbsize = 0; DPRINTK(" Detailed Timings\n");