The netconsole change that started using nbcon_write_context for CPU and task information assumes CONFIG_PRINTK_EXECUTION_CTX is enabled. However, when this option is disabled, struct nbcon_write_context does not contain the cpu and comm fields, causing compilation failures: error: 'struct nbcon_write_context' has no member named 'cpu' error: 'struct nbcon_write_context' has no member named 'comm' Guard access to these fields and fall back to raw_smp_processor_id() and current->comm when PRINTK_EXECUTION_CTX is disabled. Fixes: 79ba362b4337 ("netconsole: Use printk context for CPU and task information") Signed-off-by: Chelsy Ratnawat --- drivers/net/netconsole.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 3c9acd6e49e8..bbd39b2e7a36 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1494,17 +1494,30 @@ static void populate_configfs_item(struct netconsole_target *nt, static int sysdata_append_cpu_nr(struct netconsole_target *nt, int offset, struct nbcon_write_context *wctxt) { + int cpu; +#ifdef CONFIG_PRINTK_EXECUTION_CTX + cpu = wctxt->cpu; +#else + cpu = raw_smp_processor_id(); +#endif + return scnprintf(&nt->sysdata[offset], MAX_EXTRADATA_ENTRY_LEN, " cpu=%u\n", - wctxt->cpu); + cpu); } static int sysdata_append_taskname(struct netconsole_target *nt, int offset, struct nbcon_write_context *wctxt) { + const char *comm; +#ifdef CONFIG_PRINTK_EXECUTION_CTX + comm = wctxt->comm; +#else + comm = current->comm; +#endif return scnprintf(&nt->sysdata[offset], MAX_EXTRADATA_ENTRY_LEN, " taskname=%s\n", - wctxt->comm); + comm); } static int sysdata_append_release(struct netconsole_target *nt, int offset) -- 2.47.3