mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-06 20:03:33 -04:00
UPSTREAM: interconnect: Handle memory allocation errors
When we allocate memory, kasprintf() can fail and we must check its
return value.
Bug: 151255205
Fixes: 05309830e1f8 ("interconnect: Add a name to struct icc_path")
Signed-off-by: Georgi Djakov <georgi.djakov@linaro.org>
Link: https://lore.kernel.org/r/20200226110420.5357-2-georgi.djakov@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 3791163602f7140011a8dc1691cfe6ec0cb1ef07)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I3eced73454428bf486e511cb5065f4b75bdfe3c4
This commit is contained in:
parent
870b75db7a
commit
45bba71ccc
1 changed files with 9 additions and 0 deletions
|
|
@ -371,6 +371,11 @@ struct icc_path *of_icc_get(struct device *dev, const char *name)
|
|||
path->name = kasprintf(GFP_KERNEL, "%s-%s",
|
||||
src_node->name, dst_node->name);
|
||||
|
||||
if (!path->name) {
|
||||
kfree(path);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(of_icc_get);
|
||||
|
|
@ -502,6 +507,10 @@ struct icc_path *icc_get(struct device *dev, const int src_id, const int dst_id)
|
|||
}
|
||||
|
||||
path->name = kasprintf(GFP_KERNEL, "%s-%s", src->name, dst->name);
|
||||
if (!path->name) {
|
||||
kfree(path);
|
||||
path = ERR_PTR(-ENOMEM);
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&icc_lock);
|
||||
return path;
|
||||
|
|
|
|||
Loading…
Reference in a new issue