diff options
-rw-r--r-- | drivers/gpu/drm/radeon/r600_cs.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/gpu/drm/radeon/r600_cs.c b/drivers/gpu/drm/radeon/r600_cs.c index 4706294f0ae0..fa7c6e58205b 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[] = { | |||
159 | 159 | ||
160 | static inline bool fmt_is_valid_color(u32 format) | 160 | static inline bool fmt_is_valid_color(u32 format) |
161 | { | 161 | { |
162 | if (format > ARRAY_SIZE(color_formats_table)) | 162 | if (format >= ARRAY_SIZE(color_formats_table)) |
163 | return false; | 163 | return false; |
164 | 164 | ||
165 | if (color_formats_table[format].valid_color) | 165 | if (color_formats_table[format].valid_color) |
@@ -170,7 +170,7 @@ static inline bool fmt_is_valid_color(u32 format) | |||
170 | 170 | ||
171 | static inline bool fmt_is_valid_texture(u32 format) | 171 | static inline bool fmt_is_valid_texture(u32 format) |
172 | { | 172 | { |
173 | if (format > ARRAY_SIZE(color_formats_table)) | 173 | if (format >= ARRAY_SIZE(color_formats_table)) |
174 | return false; | 174 | return false; |
175 | 175 | ||
176 | if (color_formats_table[format].blockwidth > 0) | 176 | if (color_formats_table[format].blockwidth > 0) |
@@ -181,7 +181,7 @@ static inline bool fmt_is_valid_texture(u32 format) | |||
181 | 181 | ||
182 | static inline int fmt_get_blocksize(u32 format) | 182 | static inline int fmt_get_blocksize(u32 format) |
183 | { | 183 | { |
184 | if (format > ARRAY_SIZE(color_formats_table)) | 184 | if (format >= ARRAY_SIZE(color_formats_table)) |
185 | return 0; | 185 | return 0; |
186 | 186 | ||
187 | return color_formats_table[format].blocksize; | 187 | return color_formats_table[format].blocksize; |
@@ -190,7 +190,8 @@ static inline int fmt_get_blocksize(u32 format) | |||
190 | static inline int fmt_get_nblocksx(u32 format, u32 w) | 190 | static inline int fmt_get_nblocksx(u32 format, u32 w) |
191 | { | 191 | { |
192 | unsigned bw; | 192 | unsigned bw; |
193 | if (format > ARRAY_SIZE(color_formats_table)) | 193 | |
194 | if (format >= ARRAY_SIZE(color_formats_table)) | ||
194 | return 0; | 195 | return 0; |
195 | 196 | ||
196 | bw = color_formats_table[format].blockwidth; | 197 | bw = color_formats_table[format].blockwidth; |
@@ -203,7 +204,8 @@ static inline int fmt_get_nblocksx(u32 format, u32 w) | |||
203 | static inline int fmt_get_nblocksy(u32 format, u32 h) | 204 | static inline int fmt_get_nblocksy(u32 format, u32 h) |
204 | { | 205 | { |
205 | unsigned bh; | 206 | unsigned bh; |
206 | if (format > ARRAY_SIZE(color_formats_table)) | 207 | |
208 | if (format >= ARRAY_SIZE(color_formats_table)) | ||
207 | return 0; | 209 | return 0; |
208 | 210 | ||
209 | bh = color_formats_table[format].blockheight; | 211 | bh = color_formats_table[format].blockheight; |
@@ -216,7 +218,8 @@ static inline int fmt_get_nblocksy(u32 format, u32 h) | |||
216 | static inline int r600_bpe_from_format(u32 *bpe, u32 format) | 218 | static inline int r600_bpe_from_format(u32 *bpe, u32 format) |
217 | { | 219 | { |
218 | unsigned res; | 220 | unsigned res; |
219 | if (format > ARRAY_SIZE(color_formats_table)) | 221 | |
222 | if (format >= ARRAY_SIZE(color_formats_table)) | ||
220 | goto fail; | 223 | goto fail; |
221 | 224 | ||
222 | res = color_formats_table[format].blocksize; | 225 | res = color_formats_table[format].blocksize; |