All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] drm/amdgpu: add amdgpu_ras.c to support ras (v2)
@ 2019-03-20 13:23 Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2019-03-20 13:23 UTC (permalink / raw)
  To: xinhui.pan-5C7GfCeVMHo; +Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hello xinhui pan,

This is a semi-automatic email about new static checker warnings.

The patch dbd249c24427: "drm/amdgpu: add amdgpu_ras.c to support ras 
(v2)" from Oct 31, 2018, leads to the following Smatch complaint:

    drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1215 amdgpu_ras_add_bad_pages()
    warn: variable dereferenced before check 'con' (see line 1211)

    drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1247 amdgpu_ras_reserve_bad_pages()
    warn: variable dereferenced before check 'con' (see line 1242)


drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
  1210		struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
  1211		struct ras_err_handler_data *data = con->eh_data;
                                                    ^^^^^^^^^^^^
Dereference

  1212		int i = pages;
  1213		int ret = 0;
  1214	
  1215		if (!con || !data || !bps || pages <= 0)
                    ^^^^
Check

  1216			return 0;
  1217	

regards,
dan carpenter
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [bug report] drm/amdgpu: add amdgpu_ras.c to support ras (v2)
@ 2020-05-05  9:12 Dan Carpenter
  2020-05-05 12:37 ` Dan Carpenter
  2020-05-06  7:26 ` Zhou1, Tao
  0 siblings, 2 replies; 7+ messages in thread
From: Dan Carpenter @ 2020-05-05  9:12 UTC (permalink / raw)
  To: xinhui.pan; +Cc: amd-gfx

Hello xinhui pan,

The patch c030f2e4166c: "drm/amdgpu: add amdgpu_ras.c to support ras
(v2)" from Oct 31, 2018, leads to the following static checker
warning:

	drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:620 amdgpu_ras_feature_enable()
	warn: uncapped user index 'ras_block_string[head->block]'

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
   587  int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
   588                  struct ras_common_if *head, bool enable)
   589  {
   590          struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
   591          union ta_ras_cmd_input info;
   592          int ret;
   593  
   594          if (!con)
   595                  return -EINVAL;
   596  
   597          if (!enable) {
   598                  info.disable_features = (struct ta_ras_disable_features_input) {
   599                          .block_id =  amdgpu_ras_block_to_ta(head->block),
   600                          .error_type = amdgpu_ras_error_to_ta(head->type),
   601                  };
   602          } else {
   603                  info.enable_features = (struct ta_ras_enable_features_input) {
   604                          .block_id =  amdgpu_ras_block_to_ta(head->block),
   605                          .error_type = amdgpu_ras_error_to_ta(head->type),
   606                  };
   607          }
   608  
   609          /* Do not enable if it is not allowed. */
   610          WARN_ON(enable && !amdgpu_ras_is_feature_allowed(adev, head));
   611          /* Are we alerady in that state we are going to set? */
   612          if (!(!!enable ^ !!amdgpu_ras_is_feature_enabled(adev, head)))
   613                  return 0;
   614  
   615          if (!amdgpu_ras_intr_triggered()) {
   616                  ret = psp_ras_enable_features(&adev->psp, &info, enable);
   617                  if (ret) {
   618                          amdgpu_ras_parse_status_code(adev,
   619                                                       enable ? "enable":"disable",
   620                                                       ras_block_str(head->block),
                                                                           ^^^^^^^^^^^
The head->block value can be set to anything using debugfs.  That's a
problem because it could easily lead to a kernel panic (which is
annoying) and also because these days we try to restrict what root can
do.

   621                                                      (enum ta_ras_status)ret);
   622                          if (ret == TA_RAS_STATUS__RESET_NEEDED)
   623                                  return -EAGAIN;
   624                          return -EINVAL;
   625                  }
   626          }
   627  
   628          /* setup the obj */
   629          __amdgpu_ras_feature_enable(adev, head, enable);
   630  
   631          return 0;
   632  }

regards,
dan carpenter
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-05-06 11:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-20 13:23 [bug report] drm/amdgpu: add amdgpu_ras.c to support ras (v2) Dan Carpenter
2020-05-05  9:12 Dan Carpenter
2020-05-05 12:37 ` Dan Carpenter
2020-05-06  7:26 ` Zhou1, Tao
2020-05-06  9:17   ` Dan Carpenter
2020-05-06 10:10     ` Pan, Xinhui
2020-05-06 11:33       ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.