Skip to content

Commit

Permalink
soc: qcom: smem: fix off-by-one error in qcom_smem_alloc_private()
Browse files Browse the repository at this point in the history
It's OK if the space for a newly-allocated uncached entry actually
touches the free cached space boundary.  It's only a problem if it
would cross it.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Andy Gross <andy.gross@linaro.org>
  • Loading branch information
Alex Elder authored and Andy Gross committed May 25, 2018
1 parent 04a512f commit 8377f81
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/soc/qcom/smem.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,

/* Check that we don't grow into the cached region */
alloc_size = sizeof(*hdr) + ALIGN(size, 8);
if ((void *)hdr + alloc_size >= cached) {
if ((void *)hdr + alloc_size > cached) {
dev_err(smem->dev, "Out of memory\n");
return -ENOSPC;
}
Expand Down

0 comments on commit 8377f81

Please sign in to comment.