All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] (ata.mod) avoid passing grub_errno to upper layer
Date: Sat, 22 Nov 2008 16:35:09 +0100	[thread overview]
Message-ID: <20081122153509.GA576@thorin> (raw)

[-- Attachment #1: Type: text/plain, Size: 659 bytes --]


Hi,

When an error is detected by ata.mod during drive scan, it will pass it to
the upper layer.  This results in GRUB aborting when trying to enter normal
mode, even if the error is not critical (e.g. affects a drive not used during
boot).

There are a number of places in ata.mod where these errors could be handled,
so I'm not sure if my proposed change would be the best approach.  Some comment
would be appreciated.

-- 
Robert Millan

  The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and
  how) you may access your data; but nobody's threatening your freedom: we
  still allow you to remove your data and not access it at all."

[-- Attachment #2: ata.diff --]
[-- Type: text/x-diff, Size: 1725 bytes --]

2008-11-22  Robert Millan  <rmh@aybabtu.com>

	* disk/ata.c (grub_ata_device_initialize): Avoid passing grub_errno
	conditions to the upper layer unless they're critical.

Index: disk/ata.c
===================================================================
--- disk/ata.c	(revision 1926)
+++ disk/ata.c	(working copy)
@@ -421,19 +421,13 @@ grub_ata_device_initialize (int port, in
   grub_ata_regset (dev, GRUB_ATA_REG_SECTORS, 0x5A);  
   grub_ata_wait ();
   if (grub_ata_regget (dev, GRUB_ATA_REG_SECTORS) != 0x5A)
-    {
-      grub_free(dev);
-      return 0;
-    }
+    goto fail;
 
   /* Detect if the device is present by issuing a EXECUTE
      DEVICE DIAGNOSTICS command.  */
   grub_ata_regset (dev, GRUB_ATA_REG_DISK, dev->device << 4);
   if (grub_ata_cmd (dev, GRUB_ATA_CMD_EXEC_DEV_DIAGNOSTICS))
-    {
-      grub_free (dev);
-      return grub_errno;
-    }
+    goto fail;
   grub_ata_wait ();
 
   grub_dprintf ("ata", "Registers: %x %x %x %x\n",
@@ -460,23 +454,29 @@ grub_ata_device_initialize (int port, in
   else
     {
       grub_dprintf ("ata", "incorrect signature\n");
-      grub_free (dev);
-      return 0;
+      goto fail;
     }
 
 
   /* Use the IDENTIFY DEVICE command to query the device.  */
   if (grub_ata_identify (dev))
-    {
-      grub_free (dev);
-      return 0;
-    }
+    goto fail;
 
   /* Register the device.  */
   for (devp = &grub_ata_devices; *devp; devp = &(*devp)->next);
   *devp = dev;
 
   return 0;
+
+ fail:
+  grub_free (dev);
+
+  /* If there were errors it means we didn't register this device.  Since other
+     devices may be fine, we don't pass this to the upper layer.  */
+  if (grub_errno)
+    grub_print_error ();
+
+  return 0;
 }
 
 static int

             reply	other threads:[~2008-11-22 15:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-22 15:35 Robert Millan [this message]
2008-11-25 21:17 ` [PATCH] (ata.mod) avoid passing grub_errno to upper layer Yoshinori K. Okuji
2008-11-28 19:37   ` Robert Millan
2008-11-29 10:01     ` Vesa Jääskeläinen
2008-11-29 12:48       ` Robert Millan
2008-11-29 18:37         ` Robert Millan
2008-11-29 21:06           ` Robert Millan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081122153509.GA576@thorin \
    --to=rmh@aybabtu.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.