On Wed, Feb 19, 2020 at 04:48:21PM -0800, Scott Branden wrote:
+static int test_dev_config_update_size_t(const char *buf,This "new" variable is long and SIZE_MAX is ULONG_MAX so the condition
+ size_t size,
+ size_t *cfg)
+{
+ int ret;
+ long new;
+
+ ret = kstrtol(buf, 10, &new);
+ if (ret)
+ return ret;
+
+ if (new > SIZE_MAX)
can't be true.
+ return -EINVAL;Both val and cfg are stack variables so there is no need for locking.
+
+ mutex_lock(&test_fw_mutex);
+ *(size_t *)cfg = new;
+ mutex_unlock(&test_fw_mutex);
+
+ /* Always return full write size even if we didn't consume all */
+ return size;
+}
+
+static ssize_t test_dev_config_show_size_t(char *buf, int cfg)
+{
+ size_t val;
+
+ mutex_lock(&test_fw_mutex);
+ val = cfg;
+ mutex_unlock(&test_fw_mutex);
Probably you meant to pass a pointer to cfg?
+regards,
+ return snprintf(buf, PAGE_SIZE, "%zu\n", val);
+}
+
static ssize_t test_dev_config_show_int(char *buf, int cfg)
{
int val;
dan carpenter