]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - lib/test_firmware.c
lib/test_string.c: avoid masking memset16/32/64 failures
[mirror_ubuntu-bionic-kernel.git] / lib / test_firmware.c
index e7008688769bbb2daceb1d8bebd0e693e0dd109f..b91b0f165498676db1e5fa8f9718a075219a10de 100644 (file)
@@ -222,30 +222,30 @@ static ssize_t config_show(struct device *dev,
 
        mutex_lock(&test_fw_mutex);
 
-       len += snprintf(buf, PAGE_SIZE,
+       len += scnprintf(buf, PAGE_SIZE - len,
                        "Custom trigger configuration for: %s\n",
                        dev_name(dev));
 
        if (test_fw_config->name)
-               len += snprintf(buf+len, PAGE_SIZE,
+               len += scnprintf(buf+len, PAGE_SIZE - len,
                                "name:\t%s\n",
                                test_fw_config->name);
        else
-               len += snprintf(buf+len, PAGE_SIZE,
+               len += scnprintf(buf+len, PAGE_SIZE - len,
                                "name:\tEMTPY\n");
 
-       len += snprintf(buf+len, PAGE_SIZE,
+       len += scnprintf(buf+len, PAGE_SIZE - len,
                        "num_requests:\t%u\n", test_fw_config->num_requests);
 
-       len += snprintf(buf+len, PAGE_SIZE,
+       len += scnprintf(buf+len, PAGE_SIZE - len,
                        "send_uevent:\t\t%s\n",
                        test_fw_config->send_uevent ?
                        "FW_ACTION_HOTPLUG" :
                        "FW_ACTION_NOHOTPLUG");
-       len += snprintf(buf+len, PAGE_SIZE,
+       len += scnprintf(buf+len, PAGE_SIZE - len,
                        "sync_direct:\t\t%s\n",
                        test_fw_config->sync_direct ? "true" : "false");
-       len += snprintf(buf+len, PAGE_SIZE,
+       len += scnprintf(buf+len, PAGE_SIZE - len,
                        "read_fw_idx:\t%u\n", test_fw_config->read_fw_idx);
 
        mutex_unlock(&test_fw_mutex);
@@ -359,7 +359,7 @@ static ssize_t config_name_show(struct device *dev,
 {
        return config_test_show_str(buf, test_fw_config->name);
 }
-static DEVICE_ATTR(config_name, 0644, config_name_show, config_name_store);
+static DEVICE_ATTR_RW(config_name);
 
 static ssize_t config_num_requests_store(struct device *dev,
                                         struct device_attribute *attr,
@@ -389,8 +389,7 @@ static ssize_t config_num_requests_show(struct device *dev,
 {
        return test_dev_config_show_u8(buf, test_fw_config->num_requests);
 }
-static DEVICE_ATTR(config_num_requests, 0644, config_num_requests_show,
-                  config_num_requests_store);
+static DEVICE_ATTR_RW(config_num_requests);
 
 static ssize_t config_sync_direct_store(struct device *dev,
                                        struct device_attribute *attr,
@@ -412,8 +411,7 @@ static ssize_t config_sync_direct_show(struct device *dev,
 {
        return test_dev_config_show_bool(buf, test_fw_config->sync_direct);
 }
-static DEVICE_ATTR(config_sync_direct, 0644, config_sync_direct_show,
-                  config_sync_direct_store);
+static DEVICE_ATTR_RW(config_sync_direct);
 
 static ssize_t config_send_uevent_store(struct device *dev,
                                        struct device_attribute *attr,
@@ -429,8 +427,7 @@ static ssize_t config_send_uevent_show(struct device *dev,
 {
        return test_dev_config_show_bool(buf, test_fw_config->send_uevent);
 }
-static DEVICE_ATTR(config_send_uevent, 0644, config_send_uevent_show,
-                  config_send_uevent_store);
+static DEVICE_ATTR_RW(config_send_uevent);
 
 static ssize_t config_read_fw_idx_store(struct device *dev,
                                        struct device_attribute *attr,
@@ -446,8 +443,7 @@ static ssize_t config_read_fw_idx_show(struct device *dev,
 {
        return test_dev_config_show_u8(buf, test_fw_config->read_fw_idx);
 }
-static DEVICE_ATTR(config_read_fw_idx, 0644, config_read_fw_idx_show,
-                  config_read_fw_idx_store);
+static DEVICE_ATTR_RW(config_read_fw_idx);
 
 
 static ssize_t trigger_request_store(struct device *dev,
@@ -838,6 +834,7 @@ static ssize_t read_firmware_show(struct device *dev,
        if (req->fw->size > PAGE_SIZE) {
                pr_err("Testing interface must use PAGE_SIZE firmware for now\n");
                rc = -EINVAL;
+               goto out;
        }
        memcpy(buf, req->fw->data, req->fw->size);