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)
Jan 16 2024, 9:53 PM
Unknown Object (File)
Dec 20 2023, 3:00 AM
Unknown Object (File)
Nov 26 2023, 2:17 PM
Unknown Object (File)
Oct 8 2023, 9:29 PM
Unknown Object (File)
Aug 26 2023, 12:31 PM
Unknown Object (File)
Jun 19 2023, 7:38 PM
Unknown Object (File)
Jun 17 2023, 4:59 PM
Unknown Object (File)
Jan 15 2023, 6:13 AM
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.