1. Apr 30, 2019
    • Wenwen Wang's avatar
      ALSA: usx2y: fix a double free bug · cbb88db7
      Wenwen Wang authored
      
      
      In usX2Y_In04_init(), a new urb is firstly created through usb_alloc_urb()
      and saved to 'usX2Y->In04urb'. Then, a buffer is allocated through
      kmalloc() and saved to 'usX2Y->In04Buf'. If the allocation of the buffer
      fails, the error code ENOMEM is returned after usb_free_urb(), which frees
      the created urb. However, the urb is actually freed at card->private_free
      callback, i.e., snd_usX2Y_card_private_free(). So the free operation here
      leads to a double free bug.
      
      To fix the above issue, simply remove usb_free_urb().
      
      Signed-off-by: default avatarWenwen Wang <wang6495@umn.edu>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      cbb88db7
  2. Apr 29, 2019
    • Bard liao's avatar
      ASoC: hdac_hda: overwrite hdev type to HDA_DEV_ASOC · b60ee2e2
      Bard liao authored
      
      
      In ASoC driver, snd_hdac_device_register() will be called by
      snd_hdac_ext_bus_device_init() and snd_hdac_device_unregister()
      will called by snd_hdac_ext_bus_device_remove(). However when
      ASoC codec driver call snd_hda_codec_device_new() to create a
      new hda codec, it will assign snd_hda_codec_dev_free() to the
      dev_free ops and snd_hda_codec_dev_free() will call
      snd_hdac_device_unregister(). As a result, snd_hdac_device_unregister()
      will be called twice in ASoC driver. To prevent it, we use hdev
      type to determine if the hda codec is registered by legacy HDA
      driver or ASoC driver and unregister device in  snd_hda_codec_dev_free()
      only if it is a legacy HDA device.
      This patch will overwrite the hdev type so that we can know it is
      a ASoC device.
      
      Signed-off-by: default avatarBard liao <yung-chuan.liao@linux.intel.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      b60ee2e2
    • Bard liao's avatar
      ALSA: hda: fix unregister device twice on ASoC driver · 4d95c517
      Bard liao authored
      
      
      snd_hda_codec_device_new() is used by both legacy HDA and ASoC
      driver. However, we will call snd_hdac_device_unregister() in
      snd_hdac_ext_bus_device_remove() for ASoC device. This patch uses
      the type flag in hdac_device struct to determine is it a ASoC device
      or legacy HDA device and call snd_hdac_device_unregister() in
      snd_hda_codec_dev_free() only if it is a legacy HDA device.
      
      Signed-off-by: default avatarBard liao <yung-chuan.liao@linux.intel.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      4d95c517
  3. Apr 28, 2019
    • Wenwen Wang's avatar
      ALSA: usb-audio: Fix a memory leak bug · cb517359
      Wenwen Wang authored
      
      
      In parse_audio_selector_unit(), the string array 'namelist' is allocated
      through kmalloc_array(), and each string pointer in this array, i.e.,
      'namelist[]', is allocated through kmalloc() in the following for loop.
      Then, a control instance 'kctl' is created by invoking snd_ctl_new1(). If
      an error occurs during the creation process, the string array 'namelist',
      including all string pointers in the array 'namelist[]', should be freed,
      before the error code ENOMEM is returned. However, the current code does
      not free 'namelist[]', resulting in memory leaks.
      
      To fix the above issue, free all string pointers 'namelist[]' in a loop.
      
      Signed-off-by: default avatarWenwen Wang <wang6495@umn.edu>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      cb517359
    • Fuqian Huang's avatar
      ALSA: gus: fix misuse of %x · 4ab1ae34
      Fuqian Huang authored
      
      
      Pointers should be printed with %p or %px rather than
      cast to long type and printed with %lx.
      Drop the address printing.
      
      Signed-off-by: default avatarFuqian Huang <huangfq.daxian@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      4ab1ae34
    • Kailang Yang's avatar
      ALSA: hda/realtek - EAPD turn on later · 607ca3bd
      Kailang Yang authored
      
      
      Let EAPD turn on after set pin output.
      
      [ NOTE: This change is supposed to reduce the possible click noises at
        (runtime) PM resume.  The functionality should be same (i.e. the
        verbs are executed correctly) no matter which order is, so this
        should be safe to apply for all codecs -- tiwai ]
      
      Signed-off-by: default avatarKailang Yang <kailang@realtek.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      607ca3bd
  4. Apr 24, 2019
  5. Apr 18, 2019
  6. Apr 17, 2019
    • Takashi Iwai's avatar
      ALSA: core: Don't refer to snd_cards array directly · f4fa9689
      Takashi Iwai authored
      
      
      The snd_cards[] array holds the card pointers that have been currently
      registered, and it's exported for the external modules that may need
      to refer a card object.  But accessing to this array can be racy
      against the driver probe or removal, as the card registration or free
      may happen concurrently.
      
      This patch gets rid of the direct access to snd_cards[] array and
      provides a helper function to give the card object from the index
      number with a refcount management.  Then the caller can access to the
      given card object safely, and releases it via snd_card_unref().
      
      While we're at it, add a proper comment to snd_card_unref() and make
      it an inlined function for type-safety, too.
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      f4fa9689
    • Takashi Iwai's avatar
      ALSA: emu10k1: Drop superfluous id-uniquification behavior · c9899549
      Takashi Iwai authored
      
      
      The emu10k1 driver tries to create a unique id string by itself when
      it's copied from the card list, but it's rather superfluous, as the
      same thing will be done in ALSA core side at the card registration.
      Let's drop the code.  This allows us removing snd_cards export.
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      c9899549
  7. Apr 15, 2019
    • Takashi Iwai's avatar
      ALSA: seq: Correct unlock sequence at snd_seq_client_ioctl_unlock() · b5fd12d6
      Takashi Iwai authored
      The doubly unlock sequence at snd_seq_client_ioctl_unlock() is tricky.
      I took a direct unref call since I thought it would avoid
      misunderstanding, but rather this seems more confusing.  Let's use
      snd_seq_client_unlock() consistently even if they look strange to be
      called twice, and add more comments for avoiding reader's confusion.
      
      Fixes: 6b580f52
      
       ("ALSA: seq: Protect racy pool manipulation from OSS sequencer")
      Reviewed-by: default avatarKai Vehmanen <kai.vehmanen@linux.intel.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      b5fd12d6
    • Roope Salmi's avatar
      ALSA: usb-audio: Add quirk for Focusrite Scarlett Solo · 46f5710f
      Roope Salmi authored
      
      
      The device reports Synch: Synchronous on the playback interface.
      This causes regular audible napping on sample rates that are not multiples
      of 1 kHz. Fix to Synch: Asynchronous.
      
      Specifically observed on Focusrite Scarlett Solo 2nd generation. I assume
      the first generation model has a different device ID. A first generation
      Scarlett 2i2 I was able to test advertised Synch: Asynchronous by default.
      
      For example, with a sample rate of 44100 Hz, a silent sample is played
      every 40.96 seconds (likely 44.0 samples instead of 44.1 transmitted per
      USB frame on average, 4096 being the size of some internal buffer).
      There may be some other bug at play here since this doesn't happen
      on other platforms. However, a feedback endpoint is listed and using it
      fixes the issue. That is the only change in the quirk,
      but I didn't find a way to declare only it.
      
      Tested on two units and on two different computers.
      
      Signed-off-by: default avatarRoope Salmi <rpsalmi@gmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      46f5710f
  8. Apr 13, 2019
  9. Apr 12, 2019
  10. Apr 11, 2019
  11. Apr 10, 2019
  12. Apr 09, 2019
    • Takashi Iwai's avatar
      ALSA: seq: Remove superfluous irqsave flags · f823b8a7
      Takashi Iwai authored
      
      
      spin_lock_irqsave() is used unnecessarily in various places in
      sequencer core code although it's pretty obvious that the context is
      sleepable.  Remove irqsave and use the plain spin_lock_irq() in such
      places for simplicity.
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      f823b8a7
    • Takashi Iwai's avatar
      ALSA: seq: Align temporary re-locking with irqsave version · 4b24b960
      Takashi Iwai authored
      
      
      In a few places in sequencer core, we temporarily unlock / re-lock the
      pool spin lock while waiting for the allocation in the blocking mode.
      There spin_unlock_irq() / spin_lock_irq() pairs are called while
      initially spin_lock_irqsave() is used (and spin_lock_irqrestore() at
      the end of the function again).  This is likely OK for now, but it's a
      bit confusing and error-prone.
      
      This patch replaces these temporary relocking lines with the irqsave
      variant to make the lock/unlock sequence more consistently.
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      4b24b960
    • Takashi Iwai's avatar
      ALSA: seq: Use kvmalloc() for cell pools · fd7ae83d
      Takashi Iwai authored
      
      
      Use kvmalloc() for allocating cell pools since the pool size can be
      relatively small that may be covered better by slab.
      
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      fd7ae83d
    • Takashi Iwai's avatar
      ALSA: timer: Revert active callback sync check at close · df55531b
      Takashi Iwai authored
      This is essentially a revert of the commit a7588c89 ("ALSA: timer:
      Check ack_list emptiness instead of bit flag").  The intended change
      by the commit turns out to be insufficient, as snd_timer_close*()
      always calls snd_timer_stop() that deletes the ack_list beforehand.
      
      In theory, we can change the behavior of snd_timer_stop() to sync the
      pending ack_list, but this will become a deadlock for the callback
      like sequencer that calls again snd_timer_stop() from itself.  So,
      reverting the change is a more straightforward solution.
      
      Fixes: a7588c89
      
       ("ALSA: timer: Check ack_list emptiness instead of bit flag")
      Reported-by: default avatar <syzbot+58813d77154713f4de15@syzkaller.appspotmail.com>
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      df55531b
  13. Apr 08, 2019
  14. Apr 05, 2019