Message ID | 20211011190607.104618-2-nirmoy.das@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/4] dri: do not check for NULL debugfs dentry | expand |
Am 11.10.21 um 21:06 schrieb Nirmoy Das: > For debugfs directory, it is recommended to save the result > and pass over to next debugfs API for creating debugfs > files/directories. Error conditions are handled by debugfs APIs. > > CC: Christian Koenig <christian.koenig@amd.com> > CC: Huang Rui <ray.huang@amd.com> > CC: David Airlie <airlied@linux.ie> > CC: Daniel Vetter <daniel@ffwll.ch> > > Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> Please also add a comment to ttm_debugfs_root that this can also be an ERR_PTR and should not be dereferenced. Apart from that looks good to me. Christian. > --- > drivers/gpu/drm/ttm/ttm_device.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c > index be24bb6cefd0..225ae6b0b4c2 100644 > --- a/drivers/gpu/drm/ttm/ttm_device.c > +++ b/drivers/gpu/drm/ttm/ttm_device.c > @@ -77,9 +77,6 @@ static int ttm_global_init(void) > si_meminfo(&si); > > ttm_debugfs_root = debugfs_create_dir("ttm", NULL); > - if (IS_ERR(ttm_debugfs_root)) { > - ttm_debugfs_root = NULL; > - } > > /* Limit the number of pages in the pool to about 50% of the total > * system memory. > @@ -108,8 +105,7 @@ static int ttm_global_init(void) > debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root, > &glob->bo_count); > out: > - if (ret && ttm_debugfs_root) > - debugfs_remove(ttm_debugfs_root); > + debugfs_remove(ttm_debugfs_root); > if (ret) > --ttm_glob_use_count; > mutex_unlock(&ttm_global_mutex); > -- > 2.32.0 >
On 10/12/2021 9:09 AM, Christian König wrote: > Am 11.10.21 um 21:06 schrieb Nirmoy Das: >> For debugfs directory, it is recommended to save the result >> and pass over to next debugfs API for creating debugfs >> files/directories. Error conditions are handled by debugfs APIs. >> >> CC: Christian Koenig <christian.koenig@amd.com> >> CC: Huang Rui <ray.huang@amd.com> >> CC: David Airlie <airlied@linux.ie> >> CC: Daniel Vetter <daniel@ffwll.ch> >> >> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> > > Please also add a comment to ttm_debugfs_root that this can also be an > ERR_PTR and should not be dereferenced. Thanks, I will resend with a comment to ttm_debugfs_root. Nirmoy > > Apart from that looks good to me. > > Christian. > >> --- >> drivers/gpu/drm/ttm/ttm_device.c | 6 +----- >> 1 file changed, 1 insertion(+), 5 deletions(-) >> >> diff --git a/drivers/gpu/drm/ttm/ttm_device.c >> b/drivers/gpu/drm/ttm/ttm_device.c >> index be24bb6cefd0..225ae6b0b4c2 100644 >> --- a/drivers/gpu/drm/ttm/ttm_device.c >> +++ b/drivers/gpu/drm/ttm/ttm_device.c >> @@ -77,9 +77,6 @@ static int ttm_global_init(void) >> si_meminfo(&si); >> >> ttm_debugfs_root = debugfs_create_dir("ttm", NULL); >> - if (IS_ERR(ttm_debugfs_root)) { >> - ttm_debugfs_root = NULL; >> - } >> >> /* Limit the number of pages in the pool to about 50% of the total >> * system memory. >> @@ -108,8 +105,7 @@ static int ttm_global_init(void) >> debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root, >> &glob->bo_count); >> out: >> - if (ret && ttm_debugfs_root) >> - debugfs_remove(ttm_debugfs_root); >> + debugfs_remove(ttm_debugfs_root); >> if (ret) >> --ttm_glob_use_count; >> mutex_unlock(&ttm_global_mutex); >> -- >> 2.32.0 >> >
diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index be24bb6cefd0..225ae6b0b4c2 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm/ttm_device.c @@ -77,9 +77,6 @@ static int ttm_global_init(void) si_meminfo(&si); ttm_debugfs_root = debugfs_create_dir("ttm", NULL); - if (IS_ERR(ttm_debugfs_root)) { - ttm_debugfs_root = NULL; - } /* Limit the number of pages in the pool to about 50% of the total * system memory. @@ -108,8 +105,7 @@ static int ttm_global_init(void) debugfs_create_atomic_t("buffer_objects", 0444, ttm_debugfs_root, &glob->bo_count); out: - if (ret && ttm_debugfs_root) - debugfs_remove(ttm_debugfs_root); + debugfs_remove(ttm_debugfs_root); if (ret) --ttm_glob_use_count; mutex_unlock(&ttm_global_mutex);
For debugfs directory, it is recommended to save the result and pass over to next debugfs API for creating debugfs files/directories. Error conditions are handled by debugfs APIs. CC: Christian Koenig <christian.koenig@amd.com> CC: Huang Rui <ray.huang@amd.com> CC: David Airlie <airlied@linux.ie> CC: Daniel Vetter <daniel@ffwll.ch> Signed-off-by: Nirmoy Das <nirmoy.das@amd.com> --- drivers/gpu/drm/ttm/ttm_device.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) -- 2.32.0