ASoC: wcd9xxx: Fix unprotected userspace access

Protect against memory faults while accessing userspace addresses.

Change-Id: I1433bac73d24d428749558e530e6869c2e5ee98f
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
This commit is contained in:
Patrick Daly
2017-01-25 01:05:22 -08:00
committed by Gerrit - the friendly Code Review server
parent af99b4f13a
commit ac87168797
+3 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, The Linux Foundation. All rights reserved.
* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -83,7 +83,8 @@ static int wcdcal_hwdep_ioctl_shared(struct snd_hwdep *hw,
return -EFAULT;
}
data = fw[fw_user.cal_type]->data;
memcpy(data, fw_user.buffer, fw_user.size);
if (copy_from_user(data, fw_user.buffer, fw_user.size))
return -EFAULT;
fw[fw_user.cal_type]->size = fw_user.size;
mutex_lock(&fw_data->lock);
set_bit(WCDCAL_RECIEVED, &fw_data->wcdcal_state[fw_user.cal_type]);