Skip to content

Commit

Permalink
raid/cpu: Use memcpy() instead of type punning
Browse files Browse the repository at this point in the history
The vendor may not be suitably aligned for uint32_t *.

Signed-off-by: Tavian Barnes <[email protected]>
  • Loading branch information
tavianator authored and Kent Overstreet committed Jul 12, 2024
1 parent 8b06995 commit 53d7722
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions raid/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ static inline void raid_cpu_info(char *vendor, unsigned *family, unsigned *model

raid_cpuid(0, 0, reg);

((uint32_t*)vendor)[0] = reg[1];
((uint32_t*)vendor)[1] = reg[3];
((uint32_t*)vendor)[2] = reg[2];
memcpy(vendor, &reg[1], 4);
memcpy(vendor + 4, &reg[3], 4);
memcpy(vendor + 8, &reg[2], 4);
vendor[12] = 0;

raid_cpuid(1, 0, reg);
Expand Down

0 comments on commit 53d7722

Please sign in to comment.