* [PATCH V3] drm/xe/guc: Fix dereference before NULL check
@ 2024-10-10 6:46 Everest K.C.
2024-10-10 6:54 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Everest K.C. @ 2024-10-10 6:46 UTC (permalink / raw)
To: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
mripard, tzimmermann, airlied, simona
Cc: Everest K.C., skhan, dan.carpenter, intel-xe, dri-devel,
kernel-janitors, linux-kernel
The pointer list->list is dereferenced before the NULL check.
Fix this by moving the NULL check outside the for loop, so that
the check is performed before the dereferencing.
The list->list pointer cannot be NULL so this has no effect on runtime.
It's just a correctness issue.
This issue was reported by Coverity Scan.
https://scan7.scan.coverity.com/#/project-view/51525/11354?selectedIssue=1600335
Fixes: a18c696fa5cb ("drm/xe/guc: Fix dereference before Null check")
Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
---
V2 -> V3: - Changed Null to NULL in the changelog
- Corrected typo in the changelong
- Added more description to the changelong
- Fixed the link for Coverity Report
- Removed the space after the Fixes tag
V1 -> V2: - Combined the `!list->list` check in preexisting if statement
- Added Fixes tag
- Added the link to the Coverity Scan report
drivers/gpu/drm/xe/xe_guc_capture.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_capture.c b/drivers/gpu/drm/xe/xe_guc_capture.c
index 41262bda20ed..947c3a6d0e5a 100644
--- a/drivers/gpu/drm/xe/xe_guc_capture.c
+++ b/drivers/gpu/drm/xe/xe_guc_capture.c
@@ -1531,7 +1531,7 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
{
int i;
- if (!list || list->num_regs == 0)
+ if (!list || !list->list || list->num_regs == 0)
return;
if (!regs)
@@ -1541,9 +1541,6 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
struct __guc_mmio_reg_descr desc = list->list[i];
u32 value;
- if (!list->list)
- return;
-
if (list->type == GUC_STATE_CAPTURE_TYPE_ENGINE_INSTANCE) {
value = xe_hw_engine_mmio_read32(hwe, desc.reg);
} else {
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH V3] drm/xe/guc: Fix dereference before NULL check
2024-10-10 6:46 [PATCH V3] drm/xe/guc: Fix dereference before NULL check Everest K.C.
@ 2024-10-10 6:54 ` Dan Carpenter
2024-10-10 9:33 ` Michal Wajdeczko
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2024-10-10 6:54 UTC (permalink / raw)
To: Everest K.C.
Cc: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
mripard, tzimmermann, airlied, simona, skhan, intel-xe, dri-devel,
kernel-janitors, linux-kernel
On Thu, Oct 10, 2024 at 12:46:34AM -0600, Everest K.C. wrote:
> The pointer list->list is dereferenced before the NULL check.
> Fix this by moving the NULL check outside the for loop, so that
> the check is performed before the dereferencing.
> The list->list pointer cannot be NULL so this has no effect on runtime.
> It's just a correctness issue.
>
> This issue was reported by Coverity Scan.
> https://scan7.scan.coverity.com/#/project-view/51525/11354?selectedIssue=1600335
>
> Fixes: a18c696fa5cb ("drm/xe/guc: Fix dereference before Null check")
> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
> ---
Perfect! Thanks.
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V3] drm/xe/guc: Fix dereference before NULL check
2024-10-10 6:54 ` Dan Carpenter
@ 2024-10-10 9:33 ` Michal Wajdeczko
2024-10-15 14:41 ` Dong, Zhanjun
0 siblings, 1 reply; 4+ messages in thread
From: Michal Wajdeczko @ 2024-10-10 9:33 UTC (permalink / raw)
To: Dan Carpenter, Everest K.C.
Cc: lucas.demarchi, thomas.hellstrom, rodrigo.vivi, maarten.lankhorst,
mripard, tzimmermann, airlied, simona, skhan, intel-xe, dri-devel,
kernel-janitors, linux-kernel
On 10.10.2024 08:54, Dan Carpenter wrote:
> On Thu, Oct 10, 2024 at 12:46:34AM -0600, Everest K.C. wrote:
>> The pointer list->list is dereferenced before the NULL check.
>> Fix this by moving the NULL check outside the for loop, so that
>> the check is performed before the dereferencing.
>> The list->list pointer cannot be NULL so this has no effect on runtime.
>> It's just a correctness issue.
>>
>> This issue was reported by Coverity Scan.
>> https://scan7.scan.coverity.com/#/project-view/51525/11354?selectedIssue=1600335
>>
>> Fixes: a18c696fa5cb ("drm/xe/guc: Fix dereference before Null check")
hmm, this seems wrong, shouldn't this be:
Fixes: 0f1fdf559225 ("drm/xe/guc: Save manual engine capture into
capture list")
>> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
>> ---
>
> Perfect! Thanks.
>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH V3] drm/xe/guc: Fix dereference before NULL check
2024-10-10 9:33 ` Michal Wajdeczko
@ 2024-10-15 14:41 ` Dong, Zhanjun
0 siblings, 0 replies; 4+ messages in thread
From: Dong, Zhanjun @ 2024-10-15 14:41 UTC (permalink / raw)
To: intel-xe
With the "Fixes" tag fixed, looks good to me to make Coverity happy.
Reviewed-by: Zhanjun Dong <zhanjun.dong@intel.com>
Regards,
Zhanjun Dong
On 2024-10-10 5:33 a.m., Michal Wajdeczko wrote:
>
>
> On 10.10.2024 08:54, Dan Carpenter wrote:
>> On Thu, Oct 10, 2024 at 12:46:34AM -0600, Everest K.C. wrote:
>>> The pointer list->list is dereferenced before the NULL check.
>>> Fix this by moving the NULL check outside the for loop, so that
>>> the check is performed before the dereferencing.
>>> The list->list pointer cannot be NULL so this has no effect on runtime.
>>> It's just a correctness issue.
>>>
>>> This issue was reported by Coverity Scan.
>>> https://scan7.scan.coverity.com/#/project-view/51525/11354?selectedIssue=1600335
>>>
>>> Fixes: a18c696fa5cb ("drm/xe/guc: Fix dereference before Null check")
>
> hmm, this seems wrong, shouldn't this be:
>
> Fixes: 0f1fdf559225 ("drm/xe/guc: Save manual engine capture into
> capture list")
>
>>> Signed-off-by: Everest K.C. <everestkc@everestkc.com.np>
>>> ---
>>
>> Perfect! Thanks.
>>
>> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
>>
>> regards,
>> dan carpenter
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-15 14:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-10 6:46 [PATCH V3] drm/xe/guc: Fix dereference before NULL check Everest K.C.
2024-10-10 6:54 ` Dan Carpenter
2024-10-10 9:33 ` Michal Wajdeczko
2024-10-15 14:41 ` Dong, Zhanjun
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox