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 <sunnyl@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2161280
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Debarshi Dutta <ddutta@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sunny Li
2019-07-25 20:59:43 +08:00
committed by Alex Waterman
parent 1d5698cf6a
commit 516023e1e4

View File

@@ -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;