From: Takashi Iwai Date: Tue, 22 Aug 2017 13:44:45 +0000 (+0200) Subject: Merge branch 'for-linus' into for-next X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=241bc82e62b28fdb7223b85180fd814f4963c971;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git Merge branch 'for-linus' into for-next Conflicts: sound/core/control.c --- 241bc82e62b28fdb7223b85180fd814f4963c971 diff --cc sound/core/control.c index 249140c15d64,4525e127afd9..de976a8c0177 --- a/sound/core/control.c +++ b/sound/core/control.c @@@ -1112,32 -1117,50 +1112,32 @@@ static int snd_ctl_elem_user_put(struc return change; } -static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol, - int op_flag, - unsigned int size, - unsigned int __user *tlv) +static int replace_user_tlv(struct snd_kcontrol *kctl, unsigned int __user *buf, + unsigned int size) { - struct user_element *ue = kcontrol->private_data; - int change = 0; - void *new_data; + struct user_element *ue = kctl->private_data; + unsigned int *container; + int change; - if (op_flag == SNDRV_CTL_TLV_OP_WRITE) { - if (size > 1024 * 128) /* sane value */ - return -EINVAL; + if (size > 1024 * 128) /* sane value */ + return -EINVAL; - new_data = memdup_user(tlv, size); - if (IS_ERR(new_data)) - return PTR_ERR(new_data); - mutex_lock(&ue->card->user_ctl_lock); - change = ue->tlv_data_size != size; - if (!change) - change = memcmp(ue->tlv_data, new_data, size) != 0; - kfree(ue->tlv_data); - ue->tlv_data = new_data; - ue->tlv_data_size = size; - mutex_unlock(&ue->card->user_ctl_lock); - } else { - int ret = 0; + container = memdup_user(buf, size); + if (IS_ERR(container)) + return PTR_ERR(container); - mutex_lock(&ue->card->user_ctl_lock); - if (!ue->tlv_data_size || !ue->tlv_data) { - ret = -ENXIO; - goto err_unlock; - } - if (size < ue->tlv_data_size) { - ret = -ENOSPC; - goto err_unlock; - } - if (copy_to_user(tlv, ue->tlv_data, ue->tlv_data_size)) - ret = -EFAULT; -err_unlock: - mutex_unlock(&ue->card->user_ctl_lock); - if (ret) - return ret; + change = ue->tlv_data_size != size; + if (!change) - change = memcmp(ue->tlv_data, container, size); ++ change = memcmp(ue->tlv_data, container, size) != 0; + if (!change) { + kfree(container); + return 0; } + + kfree(ue->tlv_data); + ue->tlv_data = container; + ue->tlv_data_size = size; + return change; }