Skip to content

Commit

Permalink
slab,apic: fixing a few bugs discovered by Coverity
Browse files Browse the repository at this point in the history
These bugs were discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Signed-off-by: Pawel Wieczorkiewicz <[email protected]>
  • Loading branch information
wipawel committed Nov 17, 2020
1 parent 7bba376 commit 30acb04
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions arch/x86/apic.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ static inline void apic_msr_write(x2apic_regs_t reg, uint64_t val) {

uint64_t apic_read(unsigned int reg) {
if (apic_mode == APIC_MODE_XAPIC)
return apic_mmio_read(reg);
return apic_mmio_read((xapic_regs_t) reg);
else if (apic_mode == APIC_MODE_X2APIC)
return apic_msr_read(reg);
return apic_msr_read((x2apic_regs_t) reg);
else
BUG();
UNREACHABLE();
Expand Down
3 changes: 2 additions & 1 deletion mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ void *kmalloc(size_t size) { return ktf_alloc(size); }
void *kzalloc(size_t size) {
void *ptr = ktf_alloc(size);

memset(ptr, 0, size);
if (ptr)
memset(ptr, 0, size);
return ptr;
}

Expand Down

0 comments on commit 30acb04

Please sign in to comment.