diff --git a/drivers/soc/qcom/dcc_v2.c b/drivers/soc/qcom/dcc_v2.c index 1ea6d361aa72..02e9c61f6041 100644 --- a/drivers/soc/qcom/dcc_v2.c +++ b/drivers/soc/qcom/dcc_v2.c @@ -1538,7 +1538,8 @@ static ssize_t dcc_sram_read(struct file *file, char __user *data, if (drvdata->ram_size <= *ppos) return 0; - if ((*ppos + len) > drvdata->ram_size) + if ((*ppos + len) < len + || (*ppos + len) > drvdata->ram_size) len = (drvdata->ram_size - *ppos); buf = kzalloc(len, GFP_KERNEL);