mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-24 08:09:22 +00:00
kern: Check for NULL when closing devices and disks
Add checks for NULL pointers to grub_device_close() and grub_disk_close() to make these functions more robust. Signed-off-by: Oliver Steffen <osteffen@redhat.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
33afcd187f
commit
d09387287b
2 files changed
+7
No files matched your search
@@ -71,6 +71,9 @@ grub_device_open (const char *name)
|
|||||||
grub_err_t
|
grub_err_t
|
||||||
grub_device_close (grub_device_t device)
|
grub_device_close (grub_device_t device)
|
||||||
{
|
{
|
||||||
|
if (device == NULL)
|
||||||
|
return GRUB_ERR_NONE;
|
||||||
|
|
||||||
if (device->disk)
|
if (device->disk)
|
||||||
grub_disk_close (device->disk);
|
grub_disk_close (device->disk);
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ void
|
|||||||
grub_disk_close (grub_disk_t disk)
|
grub_disk_close (grub_disk_t disk)
|
||||||
{
|
{
|
||||||
grub_partition_t part;
|
grub_partition_t part;
|
||||||
|
|
||||||
|
if (disk == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
grub_dprintf ("disk", "Closing `%s'.\n", disk->name);
|
grub_dprintf ("disk", "Closing `%s'.\n", disk->name);
|
||||||
|
|
||||||
if (disk->dev && disk->dev->disk_close)
|
if (disk->dev && disk->dev->disk_close)
|
||||||
|
|||||||
Reference in new issue
Block a user