diff mbox series

[4/4] drm/i915/guc: Don't go bang in GuC log if no GuC

Message ID 20211203000623.3086309-5-John.C.Harrison@Intel.com (mailing list archive)
State New, archived
Headers show
Series Assorted fixes/tweaks to GuC support | expand

Commit Message

John Harrison Dec. 3, 2021, 12:06 a.m. UTC
From: John Harrison <John.C.Harrison@Intel.com>

If the GuC has failed to load for any reason and then the user pokes
the debugfs GuC log interface, a BUG and/or null pointer deref can
occur. Don't let that happen.

Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Lucas De Marchi Dec. 3, 2021, 12:33 a.m. UTC | #1
On Thu, Dec 02, 2021 at 04:06:23PM -0800, John.C.Harrison@Intel.com wrote:
>From: John Harrison <John.C.Harrison@Intel.com>
>
>If the GuC has failed to load for any reason and then the user pokes
>the debugfs GuC log interface, a BUG and/or null pointer deref can
>occur. Don't let that happen.
>
>Signed-off-by: John Harrison <John.C.Harrison@Intel.com>


Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>

Lucas De Marchi

>---
> drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>index 46026c2c1722..8fd068049376 100644
>--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>@@ -31,7 +31,7 @@ static int guc_log_level_get(void *data, u64 *val)
> {
> 	struct intel_guc_log *log = data;
>
>-	if (!intel_guc_is_used(log_to_guc(log)))
>+	if (!log->vma)
> 		return -ENODEV;
>
> 	*val = intel_guc_log_get_level(log);
>@@ -43,7 +43,7 @@ static int guc_log_level_set(void *data, u64 val)
> {
> 	struct intel_guc_log *log = data;
>
>-	if (!intel_guc_is_used(log_to_guc(log)))
>+	if (!log->vma)
> 		return -ENODEV;
>
> 	return intel_guc_log_set_level(log, val);
>-- 
>2.25.1
>
Daniele Ceraolo Spurio Dec. 3, 2021, 8 p.m. UTC | #2
On 12/2/2021 4:33 PM, Lucas De Marchi wrote:
> On Thu, Dec 02, 2021 at 04:06:23PM -0800, John.C.Harrison@Intel.com 
> wrote:
>> From: John Harrison <John.C.Harrison@Intel.com>
>>
>> If the GuC has failed to load for any reason and then the user pokes
>> the debugfs GuC log interface, a BUG and/or null pointer deref can
>> occur. Don't let that happen.
>>
>> Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
>
>
> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
>
> Lucas De Marchi
>

Do we need a fixes tag? or is it ok to not have it for debugfs bugs?

Daniele

>> ---
>> drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c 
>> b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>> index 46026c2c1722..8fd068049376 100644
>> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>> @@ -31,7 +31,7 @@ static int guc_log_level_get(void *data, u64 *val)
>> {
>>     struct intel_guc_log *log = data;
>>
>> -    if (!intel_guc_is_used(log_to_guc(log)))
>> +    if (!log->vma)
>>         return -ENODEV;
>>
>>     *val = intel_guc_log_get_level(log);
>> @@ -43,7 +43,7 @@ static int guc_log_level_set(void *data, u64 val)
>> {
>>     struct intel_guc_log *log = data;
>>
>> -    if (!intel_guc_is_used(log_to_guc(log)))
>> +    if (!log->vma)
>>         return -ENODEV;
>>
>>     return intel_guc_log_set_level(log, val);
>> -- 
>> 2.25.1
>>
Lucas De Marchi Dec. 7, 2021, 7:01 a.m. UTC | #3
On Fri, Dec 03, 2021 at 12:00:59PM -0800, Daniele Ceraolo Spurio wrote:
>
>
>On 12/2/2021 4:33 PM, Lucas De Marchi wrote:
>>On Thu, Dec 02, 2021 at 04:06:23PM -0800, John.C.Harrison@Intel.com 
>>wrote:
>>>From: John Harrison <John.C.Harrison@Intel.com>
>>>
>>>If the GuC has failed to load for any reason and then the user pokes
>>>the debugfs GuC log interface, a BUG and/or null pointer deref can
>>>occur. Don't let that happen.
>>>
>>>Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
>>
>>
>>Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
>>
>>Lucas De Marchi
>>
>
>Do we need a fixes tag? or is it ok to not have it for debugfs bugs?
>

for this file in debugfs, I don't think so, but I will let the
maintainers to chime in.

Lucas De Marchi

>Daniele
>
>>>---
>>>drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c | 4 ++--
>>>1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>>diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c 
>>>b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>>>index 46026c2c1722..8fd068049376 100644
>>>--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>>>+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
>>>@@ -31,7 +31,7 @@ static int guc_log_level_get(void *data, u64 *val)
>>>{
>>>    struct intel_guc_log *log = data;
>>>
>>>-    if (!intel_guc_is_used(log_to_guc(log)))
>>>+    if (!log->vma)
>>>        return -ENODEV;
>>>
>>>    *val = intel_guc_log_get_level(log);
>>>@@ -43,7 +43,7 @@ static int guc_log_level_set(void *data, u64 val)
>>>{
>>>    struct intel_guc_log *log = data;
>>>
>>>-    if (!intel_guc_is_used(log_to_guc(log)))
>>>+    if (!log->vma)
>>>        return -ENODEV;
>>>
>>>    return intel_guc_log_set_level(log, val);
>>>-- 
>>>2.25.1
>>>
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
index 46026c2c1722..8fd068049376 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log_debugfs.c
@@ -31,7 +31,7 @@  static int guc_log_level_get(void *data, u64 *val)
 {
 	struct intel_guc_log *log = data;
 
-	if (!intel_guc_is_used(log_to_guc(log)))
+	if (!log->vma)
 		return -ENODEV;
 
 	*val = intel_guc_log_get_level(log);
@@ -43,7 +43,7 @@  static int guc_log_level_set(void *data, u64 val)
 {
 	struct intel_guc_log *log = data;
 
-	if (!intel_guc_is_used(log_to_guc(log)))
+	if (!log->vma)
 		return -ENODEV;
 
 	return intel_guc_log_set_level(log, val);