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
F169211334: D13038.id.diff
Mon, Aug 31, 8:54 PM
F169119234: D13038.diff
Mon, Aug 31, 11:32 AM
Unknown Object (File)
Sat, Aug 29, 10:54 AM
Unknown Object (File)
Sat, Aug 29, 2:57 AM
Unknown Object (File)
Sat, Aug 29, 2:51 AM
Unknown Object (File)
Wed, Aug 26, 6:32 PM
Unknown Object (File)
Sat, Aug 22, 10:53 AM
Unknown Object (File)
Fri, Aug 21, 12:18 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.