defect: driver defect cleanup
authorJiamin Ma <jiamin.ma@amlogic.com>
Thu, 29 Mar 2018 10:56:01 +0000 (18:56 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 4 Apr 2018 01:37:41 +0000 (17:37 -0800)
PD#163273: driver defect cleanup

435
477
478
479
480
482
485
486
487
488
555
573
594
617
648
650
678
855

Change-Id: Ifb2d89576e4cbb77449732d79f688c970bb0dca1
Signed-off-by: Jiamin Ma <jiamin.ma@amlogic.com>
drivers/amlogic/efuse/efuse64.c
drivers/amlogic/mailbox/meson_mhu.c
drivers/amlogic/unifykey/storagekey.c
drivers/amlogic/unifykey/unifykey.c
include/linux/memory_hotplug.h
include/linux/vmstat.h

index 71c6bbe..701f36f 100644 (file)
@@ -318,7 +318,7 @@ ssize_t efuse_user_attr_store(char *name, const char *buf, size_t count)
 
        local_buf = kzalloc(sizeof(char)*(count), GFP_KERNEL);
 
-       memcpy(local_buf, buf, strlen(buf));
+       memcpy(local_buf, buf, count);
 
        c = ":";
        s = local_buf;
@@ -569,7 +569,9 @@ int get_efusekey_info(struct device_node *np)
                        pr_err("please config keyname item\n");
                        goto err;
                }
-               strcpy(efusekey_infos[index].keyname, uname);
+               strncpy(efusekey_infos[index].keyname, uname,
+                       strlen(uname) > sizeof(efusekey_infos[index].keyname) ?
+                       sizeof(efusekey_infos[index].keyname):strlen(uname));
                ret = of_property_read_u32(np_key, "offset",
                        &(efusekey_infos[index].offset));
                if (ret) {
index 8a7f72c..45f48e7 100644 (file)
@@ -109,12 +109,10 @@ static irqreturn_t mbox_handler(int irq, void *p)
        void __iomem *payload = ctlr->payload_base;
        int idx = chan->index;
        struct mhu_data_buf *data;
-       unsigned int *pp;
        u32 status = readl(mbox_base + RX_STATUS(idx));
 
        if (status && irq == chan->rx_irq) {
                data = chan->data;
-               pp = (unsigned int *)data->rx_buf;
                if (!data)
                        return IRQ_NONE; /* spurious */
                if (data->rx_buf)
index 2c5a13f..831485f 100644 (file)
@@ -115,7 +115,7 @@ EXPORT_SYMBOL(storage_ops_write);
 int32_t amlkey_init_gen(uint8_t *seed, uint32_t len, int encrypt_type)
 {
        int32_t ret = 0;
-       uint32_t actual_size;
+       uint32_t actual_size = 0;
 
 #ifndef OTHER_METHOD_CALL
        ret = store_operation_init();
@@ -180,7 +180,7 @@ _out:
 int32_t amlkey_init_m8b(uint8_t *seed, uint32_t len, int encrypt_type)
 {
        int32_t ret = 0;
-       uint32_t actual_size;
+       uint32_t actual_size = 0;
 
 #ifndef OTHER_METHOD_CALL
        ret = store_operation_init();
index 1c89086..0d0bd83 100644 (file)
@@ -1023,9 +1023,10 @@ static ssize_t list_show(struct class *cla,
        /* show all the keys*/
        for (index = 0; index < key_cnt; index++) {
                unifykey = unifykey_find_item_by_id(&(ukdev->uk_header), index);
-               n += sprintf(&buf[n], "%02d: %s, %s, %x\n",
-                       index, unifykey->name,
-                       keydev[unifykey->dev], unifykey->permit);
+               if (unifykey != NULL)
+                       n += sprintf(&buf[n], "%02d: %s, %s, %x\n",
+                               index, unifykey->name,
+                               keydev[unifykey->dev], unifykey->permit);
        }
        buf[n] = 0;
        return n;
@@ -1339,8 +1340,8 @@ static ssize_t write_store(struct class *cla,
 
        }
 _out:
-       if (!IS_ERR_OR_NULL(keydata))
-               kfree(keydata);
+       kfree(keydata);
+       keydata = NULL;
 
        return count;
 }
index 134a2f6..7714144 100644 (file)
@@ -1,7 +1,9 @@
 #ifndef __LINUX_MEMORY_HOTPLUG_H
 #define __LINUX_MEMORY_HOTPLUG_H
 
+#ifndef CONFIG_AMLOGIC_MODIFY
 #include <linux/mmzone.h>
+#endif
 #include <linux/spinlock.h>
 #include <linux/notifier.h>
 #include <linux/bug.h>
index dde2183..c9a3343 100644 (file)
@@ -3,7 +3,9 @@
 
 #include <linux/types.h>
 #include <linux/percpu.h>
+#ifndef CONFIG_AMLOGIC_MODIFY
 #include <linux/mm.h>
+#endif
 #include <linux/mmzone.h>
 #include <linux/vm_event_item.h>
 #include <linux/atomic.h>