mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: add null check
As part of supporting GPU minimal boot, some of the HALs are assigned with NULL. Before dereferencing such HALs, check for NULL. Further, this patch reorganizes needs_init API to first check whether a function pointer is NULL, to enable quick turnaround to the caller of this API. JIRA NVGPU-9283 Change-Id: I768d1cddef8766948c99892c59f6ebe6f31be9d8 Signed-off-by: Rajesh Devaraj <rdevaraj@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2814225 Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
7abaeda619
commit
9143860355
@@ -558,10 +558,12 @@ static int nvgpu_init_boot_clk_or_clk_arb(struct gk20a *g)
|
||||
#endif
|
||||
{
|
||||
#ifdef CONFIG_NVGPU_CLK_ARB
|
||||
err = g->ops.clk_arb.clk_arb_init_arbiter(g);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "failed to init clk arb");
|
||||
return err;
|
||||
if (g->ops.clk_arb.clk_arb_init_arbiter != NULL) {
|
||||
err = g->ops.clk_arb.clk_arb_init_arbiter(g);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "failed to init clk arb");
|
||||
return err;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -586,7 +588,9 @@ static int nvgpu_init_set_debugger_mode(struct gk20a *g)
|
||||
(void)g;
|
||||
#ifdef CONFIG_NVGPU_DEBUGGER
|
||||
/* Restore the debug setting */
|
||||
g->ops.fb.set_debug_mode(g, g->mmu_debug_ctrl);
|
||||
if (g->ops.fb.set_debug_mode != NULL) {
|
||||
g->ops.fb.set_debug_mode(g, g->mmu_debug_ctrl);
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -709,8 +713,8 @@ struct nvgpu_init_table_t {
|
||||
|
||||
static bool needs_init(struct gk20a *g, nvgpu_init_func_t func, u32 enable_flag)
|
||||
{
|
||||
return ((enable_flag == NO_FLAG) ||
|
||||
nvgpu_is_enabled(g, enable_flag)) && (func != NULL);
|
||||
return (func != NULL) && ((enable_flag == NO_FLAG) ||
|
||||
nvgpu_is_enabled(g, enable_flag));
|
||||
}
|
||||
|
||||
static int nvgpu_early_init(struct gk20a *g)
|
||||
|
||||
Reference in New Issue
Block a user