From patchwork Sat Feb 26 01:48:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 591951 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 p1Q1mhFF005629 for ; Sat, 26 Feb 2011 01:49:04 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 347899E99B for ; Fri, 25 Feb 2011 17:48:43 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bw0-f49.google.com (mail-bw0-f49.google.com [209.85.214.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 502B99E75A for ; Fri, 25 Feb 2011 17:48:35 -0800 (PST) Received: by bwz1 with SMTP id 1so2626810bwz.36 for ; Fri, 25 Feb 2011 17:48:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:mime-version :content-type:content-disposition:user-agent; bh=qvmgGY0AdP1EVKNOLQzCYLod4C6XDBpQt0bvkiF5KQE=; b=AHyV1wqrMBYfHAbm5M9WShTfg7DGPjx2hrk8qCJrOZAx2zh6e9alwGhYyus38l2Bpn WcaY8/H2wFtZFqc56qsiHcLbHT8Ony8Q8Xsf5F7r99xYzwwRUlRoB8YbTj8uv1SgqAD5 D1z0kouG9tZdXYURBgFZM4RFmQ+XSFumDPAPk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=G8VHk4v5WKLKjoFa9sIAJnzTXxZFY4Mum7uox4FZZ7BmKi+FGwrQPqAHHv8iSjVqyL DMdJ3LzVRLdQfSrbElsBgcN+Ri1mkbrdTEqIA7FuRL52fzhk/HaAceVby3MLkJmSehaF XwMlJ57x25fqxxMa0HlCeh2ct9jDf8xYe/FzE= Received: by 10.204.15.83 with SMTP id j19mr1584366bka.105.1298684913910; Fri, 25 Feb 2011 17:48:33 -0800 (PST) Received: from bicker ([212.49.88.34]) by mx.google.com with ESMTPS id f20sm836555bkf.16.2011.02.25.17.48.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Feb 2011 17:48:32 -0800 (PST) Date: Sat, 26 Feb 2011 04:48:18 +0300 From: Dan Carpenter To: David Airlie Subject: [patch] drm/radeon/r600_cs: off by one errors Message-ID: <20110226014818.GB18043@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) Cc: kernel-janitors@vger.kernel.org, dri-devel@lists.freedesktop.org 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.6 (demeter1.kernel.org [140.211.167.41]); Sat, 26 Feb 2011 01:49:04 +0000 (UTC) diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c index 79ac676..41da786 100644 --- a/drivers/gpu/drm/radeon/r600_cs.c +++ b/drivers/gpu/drm/radeon/r600_cs.c @@ -159,7 +159,7 @@ static const struct gpu_formats color_formats_table[] = { static inline bool fmt_is_valid_color(u32 format) { - if (format > ARRAY_SIZE(color_formats_table)) + if (format >= ARRAY_SIZE(color_formats_table)) return false; if (color_formats_table[format].valid_color) @@ -170,7 +170,7 @@ static inline bool fmt_is_valid_color(u32 format) static inline bool fmt_is_valid_texture(u32 format) { - if (format > ARRAY_SIZE(color_formats_table)) + if (format >= ARRAY_SIZE(color_formats_table)) return false; if (color_formats_table[format].blockwidth > 0) @@ -181,7 +181,7 @@ static inline bool fmt_is_valid_texture(u32 format) static inline int fmt_get_blocksize(u32 format) { - if (format > ARRAY_SIZE(color_formats_table)) + if (format >= ARRAY_SIZE(color_formats_table)) return 0; return color_formats_table[format].blocksize; @@ -190,7 +190,8 @@ static inline int fmt_get_blocksize(u32 format) static inline int fmt_get_nblocksx(u32 format, u32 w) { unsigned bw; - if (format > ARRAY_SIZE(color_formats_table)) + + if (format >= ARRAY_SIZE(color_formats_table)) return 0; bw = color_formats_table[format].blockwidth; @@ -203,7 +204,8 @@ static inline int fmt_get_nblocksx(u32 format, u32 w) static inline int fmt_get_nblocksy(u32 format, u32 h) { unsigned bh; - if (format > ARRAY_SIZE(color_formats_table)) + + if (format >= ARRAY_SIZE(color_formats_table)) return 0; bh = color_formats_table[format].blockheight; @@ -216,7 +218,8 @@ static inline int fmt_get_nblocksy(u32 format, u32 h) static inline int r600_bpe_from_format(u32 *bpe, u32 format) { unsigned res; - if (format > ARRAY_SIZE(color_formats_table)) + + if (format >= ARRAY_SIZE(color_formats_table)) goto fail; res = color_formats_table[format].blocksize;