spi/omap2_mcspi: Check params before dereference or use
[safe/jmp/linux-2.6] / drivers / edac / edac_mc_sysfs.c
index 4794928..418b65f 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include <linux/ctype.h>
+#include <linux/slab.h>
 #include <linux/bug.h>
 
 #include "edac_core.h"
@@ -94,7 +95,9 @@ static const char *mem_types[] = {
        [MEM_DDR2] = "Unbuffered-DDR2",
        [MEM_FB_DDR2] = "FullyBuffered-DDR2",
        [MEM_RDDR2] = "Registered-DDR2",
-       [MEM_XDR] = "XDR"
+       [MEM_XDR] = "XDR",
+       [MEM_DDR3] = "Unbuffered-DDR3",
+       [MEM_RDDR3] = "Registered-DDR3"
 };
 
 static const char *dev_types[] = {
@@ -178,7 +181,11 @@ static ssize_t csrow_edac_mode_show(struct csrow_info *csrow, char *data,
 static ssize_t channel_dimm_label_show(struct csrow_info *csrow,
                                char *data, int channel)
 {
-       return snprintf(data, EDAC_MC_LABEL_LEN, "%s",
+       /* if field has not been initialized, there is nothing to send */
+       if (!csrow->channels[channel].label[0])
+               return 0;
+
+       return snprintf(data, EDAC_MC_LABEL_LEN, "%s\n",
                        csrow->channels[channel].label);
 }
 
@@ -239,7 +246,7 @@ static ssize_t csrowdev_store(struct kobject *kobj, struct attribute *attr,
        return -EIO;
 }
 
-static struct sysfs_ops csrowfs_ops = {
+static const struct sysfs_ops csrowfs_ops = {
        .show = csrowdev_show,
        .store = csrowdev_store
 };
@@ -569,7 +576,7 @@ static ssize_t mcidev_store(struct kobject *kobj, struct attribute *attr,
 }
 
 /* Intermediate show/store table */
-static struct sysfs_ops mci_ops = {
+static const struct sysfs_ops mci_ops = {
        .show = mcidev_show,
        .store = mcidev_store
 };