From patchwork Tue Jul 2 08:57:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 2811271 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id BEAAB9F755 for ; Tue, 2 Jul 2013 09:09:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1A8B20136 for ; Tue, 2 Jul 2013 09:09:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 31C1D20121 for ; Tue, 2 Jul 2013 09:09:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1F628E61B7 for ; Tue, 2 Jul 2013 02:09:55 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id DF3E0E61BE for ; Tue, 2 Jul 2013 01:56:52 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MPA002W7WURHPK0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Tue, 02 Jul 2013 17:56:51 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.115]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 1E.78.03969.3D592D15; Tue, 02 Jul 2013 17:56:51 +0900 (KST) X-AuditID: cbfee68f-b7f436d000000f81-1b-51d295d3aaa6 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A8.B4.28381.3D592D15; Tue, 02 Jul 2013 17:56:51 +0900 (KST) Received: from localhost.localdomain ([10.90.8.56]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MPA00ABQWUP6I00@mmp1.samsung.com>; Tue, 02 Jul 2013 17:56:51 +0900 (KST) From: Seung-Woo Kim To: dri-devel@lists.freedesktop.org, airlied@linux.ie Subject: [PATCH v3 2/3] drm: add assertion for checking null edid to drm_edid_block_valid Date: Tue, 02 Jul 2013 17:57:04 +0900 Message-id: <1372755424-7301-1-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <20130702082923.GJ5004@intel.com> References: <20130702082923.GJ5004@intel.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRmVeSWpSXmKPExsWyRsSkWPfy1EuBBt+eq1v0njvJZHHz4VlW i//bJjJbXPn6ns3ibNMbdosZk1+yWXz/t5DJYu/OyYwOHB4rP2h57P22gMVj+7cHrB7zTgZ6 3O8+zuTRt2UVYwBbFJdNSmpOZllqkb5dAlfGgpObmQsO8FSsObeBsYHxP2cXIyeHhICJxI2G tcwQtpjEhXvr2boYuTiEBJYyShxa94EFpujI7cssEIlFjBKXT09gBEkICTQzSaxaBzaJTUBH Yv+S36wgtoiAqcTZy9eYQRqYBaYzSjz5ewtskrBAtMSbLY/BbBYBVYl7y+6ygdi8Aq4S/Vu2 MUFsU5BYcO8tWJxTQE9iwuGfQIM4gJbpStw+VQoyU0JgHbvEuiPn2CHmCEh8m3yIBaRGQkBW YtMBqG8kJQ6uuMEygVF4ASPDKkbR1ILkguKk9CJjveLE3OLSvHS95PzcTYzAwD/971n/Dsa7 B6wPMSYDjZvILCWanA+MnLySeENjMyMLUxNTYyNzSzPShJXEedVarAOFBNITS1KzU1MLUovi i0p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1WYinOSDTU Yi4qTgQAMzV0Tu8CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: sw0312.kim@samsung.com, yj44.cho@samsung.com, kyungmin.park@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 If raw_edid of drm_edid_block_vaild() is null, it will crash, so checking in bad label is removed and instead assertion is added at the top of the function. The type of return for the function is bool, so it fixes to return true and false instead of 1 and 0. Signed-off-by: Seung-Woo Kim Signed-off-by: Kyungmin Park Reviewed-by: Chris Wilson --- change from v2 - check result of WARN_ON() as Ville's comment chages from v1 - NULL checking is replaced with WARN_ON() as Daniel commented - all return value is replaced as true/false as Chris and Daniel commented drivers/gpu/drm/drm_edid.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 2dc1a60..95d6f4b 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -968,6 +968,9 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid) u8 csum = 0; struct edid *edid = (struct edid *)raw_edid; + if (WARN_ON(!raw_edid)) + return false; + if (edid_fixup > 8 || edid_fixup < 0) edid_fixup = 6; @@ -1010,15 +1013,15 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid) break; } - return 1; + return true; bad: - if (raw_edid && print_bad_edid) { + if (print_bad_edid) { printk(KERN_ERR "Raw EDID:\n"); print_hex_dump(KERN_ERR, " \t", DUMP_PREFIX_NONE, 16, 1, raw_edid, EDID_LENGTH, false); } - return 0; + return false; } EXPORT_SYMBOL(drm_edid_block_valid);