Hi Dan,Removed the check.
Thanks for your review and valuable comments.
Will have to investigate fully and correct anything wrong.
On 2020-02-20 12:42 a.m., Dan Carpenter wrote:
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.
I am following the existing code as was done for
+ÂÂÂÂÂÂÂ 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