Re: [PATCH v2 3/7] test_firmware: add partial read support for request_firmware_into_buf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Reponses inline.

Luis - please have a look as well.

On 2020-02-21 10:30 a.m., Scott Branden wrote:
Hi Dan,

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,
+                     size_t size,
+                     size_t *cfg)
+{
+    int ret;
+    long new;
+
+    ret = kstrtol(buf, 10, &new);
+    if (ret)
+        return ret;
+
+    if (new > SIZE_MAX)
This "new" variable is long and SIZE_MAX is ULONG_MAX so the condition
can't be true.
Removed the check.

+        return -EINVAL;
+
+    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);
Both val and cfg are stack variables so there is no need for locking.
Probably you meant to pass a pointer to cfg?
I am following the existing code as was done for
test_dev_config_show_bool(),
test_dev_config_show_int(),
test_dev_config_show_u8()

Mutex probably not needed but I don't think I need to deviate from the rest of the test code.

Luis, could you please explain what the rest of your code is doing?

+
+    return snprintf(buf, PAGE_SIZE, "%zu\n", val);
+}
+
  static ssize_t test_dev_config_show_int(char *buf, int cfg)
  {
      int val;
regards,
dan carpenter







[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux