Commit fe9bab2df96cec7011773aab272515b9faa9b6c4
Committed by
Linus Torvalds
1 parent
1f4d4a80fb
Exists in
master
and in
4 other branches
[PATCH] Fix sb_mixer use before validation
dev should be validated before it is being used as index to array. Coverity bug #871 Signed-off-by: Eugene Teo <eugene.teo@eugeneteo.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 3 additions and 3 deletions Side-by-side Diff
sound/oss/sb_mixer.c
| ... | ... | @@ -273,13 +273,13 @@ |
| 273 | 273 | int regoffs; |
| 274 | 274 | unsigned char val; |
| 275 | 275 | |
| 276 | + if ((dev < 0) || (dev >= devc->iomap_sz)) | |
| 277 | + return -EINVAL; | |
| 278 | + | |
| 276 | 279 | regoffs = (*devc->iomap)[dev][LEFT_CHN].regno; |
| 277 | 280 | |
| 278 | 281 | if (regoffs == 0) |
| 279 | 282 | return -EINVAL; |
| 280 | - | |
| 281 | - if ((dev < 0) || (dev >= devc->iomap_sz)) | |
| 282 | - return -EINVAL; | |
| 283 | 283 | |
| 284 | 284 | val = sb_getmixer(devc, regoffs); |
| 285 | 285 | change_bits(devc, &val, dev, LEFT_CHN, left); |