1
0
mirror of https://github.com/sgmarz/osblog.git synced 2024-11-24 02:16:19 +04:00

Add sanity check from kmalloc. Don't zero if it is null

This commit is contained in:
Stephen Marz 2019-10-10 08:45:39 -04:00
parent a110d17355
commit 450a152b24

View File

@ -87,11 +87,13 @@ pub fn kzmalloc(sz: usize) -> *mut u8 {
let size = align_val(sz, 3); let size = align_val(sz, 3);
let ret = kmalloc(size); let ret = kmalloc(size);
if !ret.is_null() {
for i in 0..size { for i in 0..size {
unsafe { unsafe {
(*ret.add(i)) = 0; (*ret.add(i)) = 0;
} }
} }
}
ret ret
} }