Index: /lm-sensors/branches/lm-sensors-2.10/prog/sensors/main.c
===================================================================
--- /lm-sensors/branches/lm-sensors-2.10/prog/sensors/main.c	(revision 5364)
+++ /lm-sensors/branches/lm-sensors-2.10/prog/sensors/main.c	(revision 5738)
@@ -93,4 +93,12 @@
 }
 
+void free_chip_names()
+{
+  int i;
+
+  for (i = 0; i < chips_count; i++)
+    free(chips[i].prefix);
+}
+
 /* This examines global var config_file, and leaves the name there too. 
    It also opens config_file. */
@@ -106,4 +114,5 @@
     fprintf(stderr, "Could not open config file\n");
     perror(config_file_name);
+    free_chip_names();
     exit(1);
   }
@@ -222,8 +231,10 @@
       if ((res = sensors_parse_chip_name(argv[i],chips+chips_count))) {
         fprintf(stderr,"Parse error in chip name `%s'\n",argv[i]);
+        free_chip_names();
         print_short_help();
         exit(1);
       } else if (++chips_count == CHIPS_MAX) {
         fprintf(stderr,"Too many chips on command line!\n");
+        free_chip_names();
         exit(1);
       }
@@ -239,4 +250,5 @@
               "For 2.6 kernels, make sure you have mounted sysfs and libsensors\n"
               "was compiled with sysfs support!\n");
+    free_chip_names();
     sensors_cleanup();
     exit(1);
@@ -247,4 +259,5 @@
 
   if(do_the_real_work(&error)) {
+    free_chip_names();
     sensors_cleanup();
     exit(error);
@@ -257,4 +270,5 @@
     else
 	    fprintf(stderr,"Specified sensor(s) not found!\n");
+    free_chip_names();
     sensors_cleanup();
     exit(1);
Index: /lm-sensors/branches/lm-sensors-2.10/prog/sensord/sensord.h
===================================================================
--- /lm-sensors/branches/lm-sensors-2.10/prog/sensord/sensord.h	(revision 4810)
+++ /lm-sensors/branches/lm-sensors-2.10/prog/sensord/sensord.h	(revision 5738)
@@ -47,4 +47,5 @@
 extern int parseArgs (int argc, char **argv);
 extern int parseChips (int argc, char **argv);
+extern void freeChips ();
 
 /* from lib.c */
Index: /lm-sensors/branches/lm-sensors-2.10/prog/sensord/args.c
===================================================================
--- /lm-sensors/branches/lm-sensors-2.10/prog/sensord/args.c	(revision 4821)
+++ /lm-sensors/branches/lm-sensors-2.10/prog/sensord/args.c	(revision 5738)
@@ -299,4 +299,6 @@
       if ((err = sensors_parse_chip_name (arg, chipNames + i))) {
         fprintf (stderr, "Invalid chip name `%s': %s\n", arg, sensors_strerror (err));
+        for (-- i; i >= 0; -- i)
+          free (chipNames[i].prefix);
         return -1;
       }
@@ -306,2 +308,10 @@
   return 0;
 }
+
+void
+freeChips
+() {
+  int i;
+  for (i = 0; i < numChipNames; ++ i)
+    free (chipNames[i].prefix);
+}
Index: /lm-sensors/branches/lm-sensors-2.10/prog/sensord/sensord.c
===================================================================
--- /lm-sensors/branches/lm-sensors-2.10/prog/sensord/sensord.c	(revision 5572)
+++ /lm-sensors/branches/lm-sensors-2.10/prog/sensord/sensord.c	(revision 5738)
@@ -200,6 +200,8 @@
   
   if (initLib () ||
-      loadLib ())
-    exit (EXIT_FAILURE);
+      loadLib ()) {
+    freeChips ();
+    exit (EXIT_FAILURE);
+  }
 
   if (isDaemon)
@@ -226,4 +228,5 @@
   }
   
+  freeChips ();
   if (unloadLib ())
     exit (EXIT_FAILURE);
Index: /lm-sensors/branches/lm-sensors-2.10/CHANGES
===================================================================
--- /lm-sensors/branches/lm-sensors-2.10/CHANGES	(revision 5707)
+++ /lm-sensors/branches/lm-sensors-2.10/CHANGES	(revision 5738)
@@ -8,4 +8,6 @@
   Module i2c-piix4: ATI SB800 is not actually supported
   Module it87: Properly decode -128 degrees C (2.6 backport)
+  Program sensord: Fix a memory leak when a chip name is provided
+  Program sensors: Fix a memory leak when a chip name is provided
   Program sensors-detect: Fix detection of older DS1621
 
