Message ID | 20241025024602.24318-6-qiuxu.zhuo@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | x86/mce: Clean up some x86/mce code | expand |
On Fri, Oct 25, 2024 at 10:45:57AM +0800, Qiuxu Zhuo wrote: > mce_numrecords = max(MCE_MIN_ENTRIES, num_possible_cpus() * MCE_PER_CPU); > mce_poolsz = mce_numrecords * (1 << order); > mce_pool = kmalloc(mce_poolsz, GFP_KERNEL); > if (!mce_pool) { > gen_pool_destroy(gpool); > - return ret; > + return -ENOMEM; This patch is just silly: the function is not that huge not to be able to see at a quick glance that it is -ENOMEM that is being returned in all error cases ... > } > ret = gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1); > if (ret) { ... except in this case where, oh well, actually, it is -ENOMEM again but you have to go down the bowells of genalloc to see it. All in all, this is causing more churn than actually improving something...
diff --git a/arch/x86/kernel/cpu/mce/genpool.c b/arch/x86/kernel/cpu/mce/genpool.c index 4284749ec803..64dffb50335a 100644 --- a/arch/x86/kernel/cpu/mce/genpool.c +++ b/arch/x86/kernel/cpu/mce/genpool.c @@ -118,22 +118,21 @@ int mce_gen_pool_add(struct mce *mce) static int mce_gen_pool_create(void) { - int mce_numrecords, mce_poolsz, order; + int mce_numrecords, mce_poolsz, order, ret; struct gen_pool *gpool; - int ret = -ENOMEM; void *mce_pool; order = order_base_2(sizeof(struct mce_evt_llist)); gpool = gen_pool_create(order, -1); if (!gpool) - return ret; + return -ENOMEM; mce_numrecords = max(MCE_MIN_ENTRIES, num_possible_cpus() * MCE_PER_CPU); mce_poolsz = mce_numrecords * (1 << order); mce_pool = kmalloc(mce_poolsz, GFP_KERNEL); if (!mce_pool) { gen_pool_destroy(gpool); - return ret; + return -ENOMEM; } ret = gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1); if (ret) { @@ -144,7 +143,7 @@ static int mce_gen_pool_create(void) mce_evt_pool = gpool; - return ret; + return 0; } int mce_gen_pool_init(void)