]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix uninitialized data in EFI RTC /proc interface
authorAndrew Morton <akpm@osdl.org>
Sat, 27 Mar 2004 05:02:21 +0000 (21:02 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Sat, 27 Mar 2004 05:02:21 +0000 (21:02 -0800)
From: Bjorn Helgaas <bjorn.helgaas@hp.com>

The problem is that we don't clear out the efi_time_t buffer before asking
EFI to fill it in.  EFI doesn't always write the entire buffer (in
particular, the alarm time only supports one second resolution, so the
nanosecond field is often untouched).

The effect is that 'cat /proc/driver/efirtc' shows garbage in the
nanoseconds part of the alarm time, and sometimes artifacts like bogus
alarm date and junk after the actual end of the text.

drivers/char/efirtc.c

index 893716b679bc1c3cfe4c4128c7c30a34f735c814..6d0b8129857ccf352315a0794d12e345685cc65b 100644 (file)
@@ -6,13 +6,13 @@
  *
  * Based on skeleton from the drivers/char/rtc.c driver by P. Gortmaker
  *
- * This code provides a architected & portable interface to the real time 
+ * This code provides an architected & portable interface to the real time
  * clock by using EFI instead of direct bit fiddling. The functionalities are 
  * quite different from the rtc.c driver. The only way to talk to the device 
  * is by using ioctl(). There is a /proc interface which provides the raw 
  * information.
  *
- * Please note that we have kept the API as close as possible from the 
+ * Please note that we have kept the API as close as possible to the
  * legacy RTC. The standard /sbin/hwclock program should work normally 
  * when used to get/set the time.
  *
@@ -297,7 +297,7 @@ static struct miscdevice efi_rtc_dev=
 };
 
 /*
- *     We export RAW EFI information to /proc/efirtc
+ *     We export RAW EFI information to /proc/driver/efirtc
  */
 static int
 efi_rtc_get_status(char *buf)
@@ -308,6 +308,10 @@ efi_rtc_get_status(char *buf)
        efi_bool_t      enabled, pending;       
        unsigned long   flags;
 
+       memset(&eft, 0, sizeof(eft));
+       memset(&alm, 0, sizeof(alm));
+       memset(&cap, 0, sizeof(cap));
+
        spin_lock_irqsave(&efi_rtc_lock, flags);
 
        efi.get_time(&eft, &cap);