From 516023e1e4009454bc724de74829f05bdf95ed2c Mon Sep 17 00:00:00 2001 From: Sunny Li Date: Thu, 25 Jul 2019 20:59:43 +0800 Subject: [PATCH] gpu: nvgpu: sysfs adding NULL pointer check golden image size will be set when memory allocated. See function: - nvgpu_gr_obj_ctx_init If golden image size is 0, gr_golden_image should be a NULL pointer in most cases. So add NULL pointer checking in tpc_pg_mask_store to avoid NULL pointer exception. Bug 2403210 Change-Id: I14df5cd94d7a4418c3089c5f84b6eab93c485ba6 Signed-off-by: Sunny Li Reviewed-on: https://git-master.nvidia.com/r/2161280 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Debarshi Dutta GVS: Gerrit_Virtual_Submit Reviewed-by: Deepak Nibade Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/os/linux/sysfs.c b/drivers/gpu/nvgpu/os/linux/sysfs.c index 0ad12aa61..98c86f9c9 100644 --- a/drivers/gpu/nvgpu/os/linux/sysfs.c +++ b/drivers/gpu/nvgpu/os/linux/sysfs.c @@ -853,7 +853,9 @@ static ssize_t tpc_pg_mask_store(struct device *dev, goto exit; } - if (nvgpu_gr_obj_ctx_get_golden_image_size(gr_golden_image) != 0) { + if (gr_golden_image && + nvgpu_gr_obj_ctx_get_golden_image_size(gr_golden_image) + != 0) { nvgpu_err(g, "golden image size already initialized"); nvgpu_mutex_release(&g->tpc_pg_lock); return -ENODEV;