Commit 1ce101e
net/netlink: Use umin() to avoid min_t(int, ...) discarding high bits
The scan limit in genl_allocate_reserve_groups() is:
min_t(int, id + n_groups, mc_groups_longs * BITS_PER_LONG);
While 'id' and 'n_groups' are both 'int', 'mc_groups_longs' is
'unsigned long' (BITS_PER_LONG is 'int').
These inconsistent types (all the values are small and non-negative)
means that a simple min() fails.
When checks for masking high bits are added to min_t() that also fails.
Instead use umin() so safely convert all the values to unsigned.
Move the limit calculation outside the loop for efficiency and
readability.
Signed-off-by: David Laight <[email protected]>1 parent f57a33b commit 1ce101e
1 file changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
398 | | - | |
| 398 | + | |
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
402 | 403 | | |
403 | 404 | | |
404 | 405 | | |
| |||
414 | 415 | | |
415 | 416 | | |
416 | 417 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
| 418 | + | |
| 419 | + | |
421 | 420 | | |
422 | 421 | | |
423 | 422 | | |
| |||
0 commit comments