Page MenuHomeFreeBSD

Add check to avoid freeing null pointer in boot1.c
ClosedPublic

Authored by worldofzak_gmail.com on Nov 10 2017, 8:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 17 2024, 4:06 AM
Unknown Object (File)
Oct 17 2024, 4:06 AM
Unknown Object (File)
Oct 17 2024, 4:06 AM
Unknown Object (File)
Oct 17 2024, 3:46 AM
Unknown Object (File)
Sep 22 2024, 8:17 PM
Unknown Object (File)
Sep 16 2024, 11:46 AM
Unknown Object (File)
Sep 7 2024, 4:47 PM
Unknown Object (File)
Sep 7 2024, 3:37 PM
Subscribers

Details

Summary

This patch adds a check to avoid freeing a null pointer in boot1. This was causing a boot loop on the Raspberry Pi 3.

Test Plan
  • build boot1.efi
  • copy boot1 to the efi system partition
  • boot system

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste added a subscriber: imp.
emaste added inline comments.
sys/boot/efi/boot1/boot1.c
414 ↗(On Diff #35052)

It's not necessary to initialize this to NULL because we set it on line 462.

This revision is now accepted and ready to land.Nov 10 2017, 8:34 PM

Also for the commit message -- it's not freeing that we need to avoid, it's using the null pointer at all. free(NULL) is actually fine. it's the printf/setenv that we can't pass a NULL pointer to.

This looks good for me. We don't need the = NULL, as emaste says. And the issue is printf'ing and setenv'ing the NULL data.

sys/boot/efi/boot1/boot1.c
464 ↗(On Diff #35052)

here's where using NULL is bad. One could argue that printf in libsa should emulate the normal userland printing of NULL data as <null>. It's only a little bit of code, but boot2 may make that tricky.

sys/boot/efi/boot1/boot1.c
468 ↗(On Diff #35052)

This one also needs to be wrapped at 80 cols.

This revision was automatically updated to reflect the committed changes.