Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0b329e3b authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "soc: qcom: pil: Fix memory management when loading firmware segs"

parents 72103fa7 729827e2
Loading
Loading
Loading
Loading
+14 −6
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2010-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2010-2019, The Linux Foundation. All rights reserved.
 */

#include <linux/module.h>
@@ -908,18 +908,24 @@ static void pil_load_seg_work_fn(struct work_struct *work)

static int pil_load_segs(struct pil_desc *desc)
{
	int ret = 0;
	int seg_id = 0;
	struct pil_priv *priv = desc->priv;
	struct pil_seg_data *pil_seg_data;
	struct pil_seg *seg;
	unsigned long *err_map;

	err_map = kcalloc(priv->num_segs, sizeof(*err_map), GFP_KERNEL);
	err_map = kcalloc(BITS_TO_LONGS(priv->num_segs), sizeof(*err_map),
			  GFP_KERNEL);
	if (!err_map)
		return -ENOMEM;

	pil_seg_data = kcalloc(priv->num_segs, sizeof(*pil_seg_data),
				GFP_KERNEL);
	if (!pil_seg_data)
		return -ENOMEM;
	if (!pil_seg_data) {
		ret = -ENOMEM;
		goto out;
	}

	/* Initialize and spawn a thread for each segment */
	list_for_each_entry(seg, &desc->priv->segs, list) {
@@ -957,9 +963,11 @@ static int pil_load_segs(struct pil_desc *desc)

	/* Each segment can fail due to different reason. Send a generic err */
	if (!bitmap_empty(err_map, priv->num_segs))
		return -EFAULT;
		ret = -EFAULT;

	return 0;
out:
	kfree(err_map);
	return ret;
}

/**