mirror of
https://github.com/torvalds/linux.git
synced 2026-07-31 03:27:03 +02:00
cpufreq: qcom-hw-debug: Fix buffer overflow
Currently the hw_regs->base array size is hardcoded to 3, but some chips have more frequency domains than this, which will result in buffer overflows The array size should be dynamically allocated according to hw_regs->domain_cnt, not hardcoded directly. Change-Id: Ida14766fe77195aef41c6e754f2875b5a24fe742 Signed-off-by: Xubin Bai <quic_xubibai@quicinc.com>
This commit is contained in:
parent
6bcead9de0
commit
caed56e132
|
|
@ -23,7 +23,7 @@ enum debug_hw_regs_data {
|
|||
};
|
||||
|
||||
struct cpufreq_hwregs {
|
||||
void __iomem *base[REG_ARRAY_SIZE];
|
||||
void * __iomem *base;
|
||||
int domain_cnt;
|
||||
struct dentry *debugfs_base;
|
||||
};
|
||||
|
|
@ -134,6 +134,11 @@ static int cpufreq_get_hwregs(struct platform_device *pdev)
|
|||
|
||||
hw_regs->domain_cnt = prop->length / (2 * sizeof(prop->length));
|
||||
|
||||
hw_regs->base = devm_kzalloc(&pdev->dev,
|
||||
hw_regs->domain_cnt * sizeof(base), GFP_KERNEL);
|
||||
if (!hw_regs->base)
|
||||
return -ENOMEM;
|
||||
|
||||
for (i = 0; i < hw_regs->domain_cnt; i++) {
|
||||
ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
|
||||
"qcom,freq-hw-domain", 1, i, &args);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user