From patchwork Thu Sep 23 10:05:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Tygier X-Patchwork-Id: 201582 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o8NA5kKT017729 for ; Thu, 23 Sep 2010 10:06:22 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C47269EFEF for ; Thu, 23 Sep 2010 03:05:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.10]) by gabe.freedesktop.org (Postfix) with ESMTP id 863739E8D3 for ; Thu, 23 Sep 2010 03:05:39 -0700 (PDT) Received: from [192.168.1.149] (87-127-117-246.static.enta.net [87.127.117.246]) by mrelayeu.kundenserver.de (node=mrbap1) with ESMTP (Nemesis) id 0LwXF9-1Ojmv82RVX-017rzv; Thu, 23 Sep 2010 12:05:37 +0200 Message-ID: <4C9B2670.9030108@yahoo.co.uk> Date: Thu, 23 Sep 2010 11:05:36 +0100 From: Sam Tygier User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 To: dri-devel@lists.freedesktop.org Subject: Re: [PATCH] DRM: ignore invalid EDID extensions References: <4C992B73.5040605@yahoo.co.uk> <1285189149.4364.3458.camel@atropine> <4C9A7857.2070004@yahoo.co.uk> <1285192509.4364.3523.camel@atropine> In-Reply-To: <1285192509.4364.3523.camel@atropine> X-Provags-ID: V02:K0:rua5c9Ynpp+Oqy7UIkwmnJ61AR6k3VNIz7T13OaNsd/ Z5S5Svix1ilM+8Kr5RXxzVHWKnQxdOB959ceEKvEnR6dWtUzMz 6ysVU/K26jGi5GAn+dXBAqRL/tw47xnBjqt5isWXjeqzzOZcl5 we46nH3lE1w+mxWGR0QZDcpQAS7vYPPGghCKLdhefl5cN/Vt6l Qddc5fkbk29VxVtvQVNXg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Sep 2010 10:06:22 +0000 (UTC) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 96e9631..2e208fa 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -241,7 +241,7 @@ drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf, .addr = DDC_ADDR, .flags = I2C_M_RD, .len = len, - .buf = buf + start, + .buf = buf, } }; @@ -254,7 +254,7 @@ drm_do_probe_ddc_edid(struct i2c_adapter *adapter, unsigned char *buf, static u8 * drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) { - int i, j = 0; + int i, j = 0, valid_extensions = 0; u8 *block, *new; if ((block = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) @@ -281,14 +281,28 @@ drm_do_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter) for (j = 1; j <= block[0x7e]; j++) { for (i = 0; i < 4; i++) { - if (drm_do_probe_ddc_edid(adapter, block, j, - EDID_LENGTH)) + if (drm_do_probe_ddc_edid(adapter, + block + (valid_extensions + 1) * EDID_LENGTH, + j, EDID_LENGTH)) goto out; - if (drm_edid_block_valid(block + j * EDID_LENGTH)) + if (drm_edid_block_valid(block + (valid_extensions + 1) * EDID_LENGTH)) { + valid_extensions++; break; + } } if (i == 4) - goto carp; + dev_warn(connector->dev->dev, + "%s: Ignoring invalid EDID block %d.\n", + drm_get_connector_name(connector), j); + } + + if (valid_extensions != block[0x7e]) { + block[EDID_LENGTH-1] += block[0x7e] - valid_extensions; + block[0x7e] = valid_extensions; + new = krealloc(block, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); + if (!new) + goto out; + block = new; } return block;