All of lore.kernel.org
 help / color / mirror / Atom feed
From: Erwan Velu <erwanaliasr1@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org
Subject: [PATCH] dmi_check_system can generate Warnings when no DMI table is present
Date: Fri, 23 Oct 2009 11:34:39 +0200	[thread overview]
Message-ID: <4AE178AF.3010804@gmail.com> (raw)

When running the Linux Kernel, on some systems that doesn't have any DMI 
table (like a Xen domU), some dmi_* calls can generates Warnings like :

>/ WARNING: at /usr/src/linux-2.6.29.1/drivers/firmware/dmi_scan.c:425/
>/ dmi_matches+0x7e/0x80()/
>/ dmi check: not initialized yet/

Some users reported this error :
http://lists.xensource.com/archives/html/xen-users/2009-04/msg00128.html
https://qa.mandriva.com/show_bug.cgi?id=54775

When the kernel is compiled with CONFIG_DMI, dmi_check_system(), 
dmi_first_match(), dmi_name_in_vendors(), dmi_find_device(), 
dmi_get_date(), dmi_match() calls doesn't check the status of the 
dmi_available variable.

When this functions are called and if no valid dmi table has been found, 
this pretty simple patch just return the default values returned when 
CONFIG_DMI isn't set.

This patch applies to the lastest git tree.
I'm CCing the x86 maintainers as I can't find any maintainer of 
drivers/firmware/dmi.

Signed-off-by: Erwan Velu <erwanaliasr1@gmail.com>


diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 938100f..ea8b433 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -457,6 +457,9 @@ int dmi_check_system(const struct dmi_system_id *list)
     int count = 0;
     const struct dmi_system_id *d;
 
+    if (!dmi_available)
+        return 0;
+
     for (d = list; d->ident; d++)
         if (dmi_matches(d)) {
             count++;
@@ -484,6 +487,9 @@ const struct dmi_system_id *dmi_first_match(const 
struct dmi_system_id *list)
 {
     const struct dmi_system_id *d;
 
+    if (!dmi_available)
+        return NULL;
+
     for (d = list; d->ident; d++)
         if (dmi_matches(d))
             return d;
@@ -501,6 +507,9 @@ EXPORT_SYMBOL(dmi_first_match);
  */
 const char *dmi_get_system_info(int field)
 {
+    if (!dmi_available)
+        return NULL;
+
     return dmi_ident[field];
 }
 EXPORT_SYMBOL(dmi_get_system_info);
@@ -512,6 +521,10 @@ EXPORT_SYMBOL(dmi_get_system_info);
 int dmi_name_in_serial(const char *str)
 {
     int f = DMI_PRODUCT_SERIAL;
+
+    if (!dmi_available)
+        return 0;
+
     if (dmi_ident[f] && strstr(dmi_ident[f], str))
         return 1;
     return 0;
@@ -527,6 +540,10 @@ int dmi_name_in_vendors(const char *str)
                 DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
                 DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_NONE };
     int i;
+
+    if (!dmi_available)
+        return 0;
+
     for (i = 0; fields[i] != DMI_NONE; i++) {
         int f = fields[i];
         if (dmi_ident[f] && strstr(dmi_ident[f], str))
@@ -554,6 +571,9 @@ const struct dmi_device * dmi_find_device(int type, 
const char *name,
     const struct list_head *head = from ? &from->list : &dmi_devices;
     struct list_head *d;
 
+    if (!dmi_available)
+        return NULL;
+
     for(d = head->next; d != &dmi_devices; d = d->next) {
         const struct dmi_device *dev =
             list_entry(d, struct dmi_device, list);
@@ -592,6 +612,16 @@ bool dmi_get_date(int field, int *yearp, int 
*monthp, int *dayp)
     const char *s, *y;
     char *e;
 
+    if (!dmi_available) {
+            if (yearp)
+                    *yearp = 0;
+            if (monthp)
+                    *monthp = 0;
+            if (dayp)
+                    *dayp = 0;
+            return false;
+    }
+
     s = dmi_get_system_info(field);
     exists = s;
     if (!exists)
@@ -676,6 +706,9 @@ bool dmi_match(enum dmi_field f, const char *str)
 {
     const char *info = dmi_get_system_info(f);
 
+    if (!dmi_available)
+        return false;
+
     if (info == NULL || str == NULL)
         return info == str;
 


             reply	other threads:[~2009-10-23  9:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-23  9:34 Erwan Velu [this message]
2009-10-23 10:08 ` [PATCH] dmi_check_system can generate Warnings when no DMI table is present Daniel Walker
2009-10-23 10:34   ` Erwan Velu
2009-10-23 10:42     ` Daniel Walker
2009-10-23 10:46       ` Erwan Velu
2009-10-23 11:00         ` Ingo Molnar
2009-10-23 11:03 ` Ingo Molnar
2009-10-23 11:49   ` Erwan Velu
2009-10-23 12:47     ` Daniel Walker
2009-10-23 15:03       ` Erwan Velu
2009-10-23 15:09         ` Daniel Walker
2009-10-23 15:30           ` Ingo Molnar
2009-10-23 17:00             ` Jeremy Fitzhardinge
2009-10-23 17:04               ` Ingo Molnar
2009-10-23 17:31                 ` Jeremy Fitzhardinge
2009-10-23 16:57 ` Jeremy Fitzhardinge

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=4AE178AF.3010804@gmail.com \
    --to=erwanaliasr1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.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.