Unverified Commit 8cf0ad32 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!3031 x86/mce/amd: Publish the bank pointer only after setup has succeeded

parents b749177e 39968f97
Loading
Loading
Loading
Loading
+16 −17
Original line number Diff line number Diff line
@@ -1200,8 +1200,9 @@ static const char *get_name(unsigned int bank, struct threshold_block *b)
	return buf_mcatype;
}

static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
				     unsigned int block, u32 address)
static int allocate_threshold_blocks(unsigned int cpu, struct threshold_bank *tb,
				     unsigned int bank, unsigned int block,
				     u32 address)
{
	struct threshold_block *b = NULL;
	u32 low, high;
@@ -1245,16 +1246,12 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,

	INIT_LIST_HEAD(&b->miscj);

	if (per_cpu(threshold_banks, cpu)[bank]->blocks) {
		list_add(&b->miscj,
			 &per_cpu(threshold_banks, cpu)[bank]->blocks->miscj);
	} else {
		per_cpu(threshold_banks, cpu)[bank]->blocks = b;
	}
	if (tb->blocks)
		list_add(&b->miscj, &tb->blocks->miscj);
	else
		tb->blocks = b;

	err = kobject_init_and_add(&b->kobj, &threshold_ktype,
				   per_cpu(threshold_banks, cpu)[bank]->kobj,
				   get_name(bank, b));
	err = kobject_init_and_add(&b->kobj, &threshold_ktype, tb->kobj, get_name(bank, b));
	if (err)
		goto out_free;
recurse:
@@ -1262,7 +1259,7 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank,
	if (!address)
		return 0;

	err = allocate_threshold_blocks(cpu, bank, block, address);
	err = allocate_threshold_blocks(cpu, tb, bank, block, address);
	if (err)
		goto out_free;

@@ -1347,8 +1344,6 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
		goto out_free;
	}

	per_cpu(threshold_banks, cpu)[bank] = b;

	if (is_shared_bank(bank)) {
		refcount_set(&b->cpus, 1);

@@ -1359,9 +1354,13 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank)
		}
	}

	err = allocate_threshold_blocks(cpu, bank, 0, msr_ops.misc(bank));
	if (!err)
		goto out;
	err = allocate_threshold_blocks(cpu, b, bank, 0, msr_ops.misc(bank));
	if (err)
		goto out_free;

	per_cpu(threshold_banks, cpu)[bank] = b;

	return 0;

 out_free:
	kfree(b);