mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
gpu: nvgpu: address NULL access during boot.
The function nvgpu_pci_probe invokes nvgpu_kzalloc(g) with a pointer to struct gk20a before setting the device pointer in struct nvgpu_os_linux. This may result in NULL Pointer access in the function nvgpu_log_name when some logs are enabled during boot. As a solution, the implementation of nvgpu_log_name is updated to first check for a valid pointer to a struct device before calling dev_name Jira NVGPU-6770 Change-Id: I98a9746550e43f3b7a143f5b7c7141ff6c67f758 Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2520355 Reviewed-by: svcacv <svcacv@nvidia.com> Reviewed-by: Lakshmanan M <lm@nvidia.com> Reviewed-by: Seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-by: Vaibhav Kachore <vkachore@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
9019661e2f
commit
6222ebeaea
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017-2019, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2017-2021, NVIDIA CORPORATION. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify it
|
* This program is free software; you can redistribute it and/or modify it
|
||||||
* under the terms and conditions of the GNU General Public License,
|
* under the terms and conditions of the GNU General Public License,
|
||||||
@@ -47,7 +47,7 @@ static const char *log_types[] = {
|
|||||||
|
|
||||||
static inline const char *nvgpu_log_name(struct gk20a *g)
|
static inline const char *nvgpu_log_name(struct gk20a *g)
|
||||||
{
|
{
|
||||||
return dev_name(dev_from_gk20a(g));
|
return dev_from_gk20a(g) == NULL ? "" : dev_name(dev_from_gk20a(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_GK20A_TRACE_PRINTK
|
#ifdef CONFIG_GK20A_TRACE_PRINTK
|
||||||
@@ -124,7 +124,7 @@ void nvgpu_log_dbg_impl(struct gk20a *g, u64 log_mask,
|
|||||||
(void) vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args);
|
(void) vsnprintf(log, LOG_BUFFER_LENGTH, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
__nvgpu_really_print_log(g->log_trace, nvgpu_log_name(g),
|
__nvgpu_really_print_log(g->log_trace, g ? nvgpu_log_name(g) : "",
|
||||||
func_name, line, NVGPU_DEBUG, log);
|
func_name, line, NVGPU_DEBUG, log);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user