1. 07 6月, 2018 1 次提交
    • K
      treewide: Use struct_size() for kmalloc()-family · acafe7e3
      Kees Cook 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
      uses. It was done via automatic conversion with manual review for the
      "CHECKME" non-standard cases noted below, using the following Coccinelle
      script:
      
      // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
      //                      sizeof *pkey_cache->table, GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // Same pattern, but can't trivially locate the trailing element name,
      // or variable name.
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      expression SOMETHING, COUNT, ELEMENT;
      @@
      
      - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
      + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      acafe7e3
  2. 19 4月, 2018 1 次提交
  3. 18 4月, 2018 1 次提交
  4. 17 4月, 2018 3 次提交
  5. 13 4月, 2018 1 次提交
  6. 12 4月, 2018 6 次提交
  7. 28 3月, 2018 4 次提交
  8. 27 3月, 2018 1 次提交
  9. 26 3月, 2018 1 次提交
  10. 22 3月, 2018 1 次提交
    • J
      ASoC: nau8824: recover system clock when device changes · b53117c0
      John Hsu 提交于
      User reports an issue in Ubuntu about the device switch upon playback.
      We find the FLL will disalbe when switching headphone to speaker.
      The pulseaudio will stop the headphone and close its power. Then,
      it just opens the speaker and turn on its power. Therefore,
      the supply of system clock does the OFF event and disables FLL.
      But the FLL doesn't enable again when the speaker powers on.
      
      The patch adds the recovery of system clock to enable FLL again
      for this case. And it covers the case that system clock from MCLK.
      Signed-off-by: NJohn Hsu <KCHSU0@nuvoton.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      b53117c0
  11. 21 3月, 2018 4 次提交
  12. 20 3月, 2018 6 次提交
  13. 19 3月, 2018 10 次提交