Commit 9f92055
iio: magnetometer: ak8975: fix potential kernel stack memory leak
[ Upstream commit a9a00d7 ]
Currently in the AK8975 driver there are four instances where potential
uninitialized kernel stack memory leaks can occur. If
i2c_smbus_read_i2c_block_data_or_emulated() returns a value less than
the size of the buffer, uninitialized bytes are retained in the buffer
and later the buffer is passed on to IIO buffers, potentially leaking
memory to userspace.
Fix this by adding checks whether the return value of the function is
equal to the size of the buffer and subsequently if the value is
lesser than zero to distinguish from a returned error code.
Fixes: bc11ca4 ("iio:magnetometer:ak8975: triggered buffer support")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260513-ak8975-fix-v1-1-104ea605dd54%40gmail.com
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 949b970 commit 9f92055
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
467 | 471 | | |
468 | 472 | | |
469 | 473 | | |
| |||
580 | 584 | | |
581 | 585 | | |
582 | 586 | | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
583 | 591 | | |
584 | 592 | | |
585 | 593 | | |
| |||
719 | 727 | | |
720 | 728 | | |
721 | 729 | | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
722 | 734 | | |
723 | 735 | | |
724 | 736 | | |
| |||
848 | 860 | | |
849 | 861 | | |
850 | 862 | | |
| 863 | + | |
| 864 | + | |
851 | 865 | | |
852 | 866 | | |
853 | 867 | | |
| |||
0 commit comments