* [Intel-gfx] [bug report] drm/i915/dmc: add i915_to_dmc() and dmc->i915 and use them
@ 2023-03-09 14:46 Dan Carpenter
2023-03-09 14:51 ` Jani Nikula
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2023-03-09 14:46 UTC (permalink / raw)
To: jani.nikula; +Cc: intel-gfx
Hello Jani Nikula,
This is a semi-automatic email about new static checker warnings.
The patch 1b28c1c789d0: "drm/i915/dmc: add i915_to_dmc() and
dmc->i915 and use them" from Mar 1, 2023, leads to the following
Smatch complaint:
drivers/gpu/drm/i915/display/intel_dmc.c:1162 intel_dmc_debugfs_status_show()
error: we previously assumed 'dmc' could be null (see line 1148)
drivers/gpu/drm/i915/display/intel_dmc.c
1142
1143 wakeref = intel_runtime_pm_get(&i915->runtime_pm);
1144
1145 seq_printf(m, "DMC initialized: %s\n", str_yes_no(dmc));'
^^^^^^^^^^^^^^^
This is a check for NULL too.
1146 seq_printf(m, "fw loaded: %s\n",
1147 str_yes_no(intel_dmc_has_payload(i915)));
1148 seq_printf(m, "path: %s\n", dmc ? dmc->fw_path : "N/A");
^^^
The patch adds a check for NULL.
1149 seq_printf(m, "Pipe A fw needed: %s\n",
1150 str_yes_no(GRAPHICS_VER(i915) >= 12));
1151 seq_printf(m, "Pipe A fw loaded: %s\n",
1152 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEA)));
1153 seq_printf(m, "Pipe B fw needed: %s\n",
1154 str_yes_no(IS_ALDERLAKE_P(i915) ||
1155 DISPLAY_VER(i915) >= 14));
1156 seq_printf(m, "Pipe B fw loaded: %s\n",
1157 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEB)));
1158
1159 if (!intel_dmc_has_payload(i915))
1160 goto out;
1161
1162 seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
^^^^^^^^^^^^
1163 DMC_VERSION_MINOR(dmc->version));
^^^^^^^^^^^^
Unchecked dereferences.
1164
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [bug report] drm/i915/dmc: add i915_to_dmc() and dmc->i915 and use them
2023-03-09 14:46 [Intel-gfx] [bug report] drm/i915/dmc: add i915_to_dmc() and dmc->i915 and use them Dan Carpenter
@ 2023-03-09 14:51 ` Jani Nikula
2023-03-10 15:19 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Jani Nikula @ 2023-03-09 14:51 UTC (permalink / raw)
To: Dan Carpenter; +Cc: intel-gfx
On Thu, 09 Mar 2023, Dan Carpenter <error27@gmail.com> wrote:
> Hello Jani Nikula,
>
> This is a semi-automatic email about new static checker warnings.
>
> The patch 1b28c1c789d0: "drm/i915/dmc: add i915_to_dmc() and
> dmc->i915 and use them" from Mar 1, 2023, leads to the following
> Smatch complaint:
>
> drivers/gpu/drm/i915/display/intel_dmc.c:1162 intel_dmc_debugfs_status_show()
> error: we previously assumed 'dmc' could be null (see line 1148)
>
> drivers/gpu/drm/i915/display/intel_dmc.c
> 1142
> 1143 wakeref = intel_runtime_pm_get(&i915->runtime_pm);
> 1144
> 1145 seq_printf(m, "DMC initialized: %s\n", str_yes_no(dmc));'
> ^^^^^^^^^^^^^^^
> This is a check for NULL too.
>
> 1146 seq_printf(m, "fw loaded: %s\n",
> 1147 str_yes_no(intel_dmc_has_payload(i915)));
> 1148 seq_printf(m, "path: %s\n", dmc ? dmc->fw_path : "N/A");
> ^^^
> The patch adds a check for NULL.
>
> 1149 seq_printf(m, "Pipe A fw needed: %s\n",
> 1150 str_yes_no(GRAPHICS_VER(i915) >= 12));
> 1151 seq_printf(m, "Pipe A fw loaded: %s\n",
> 1152 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEA)));
> 1153 seq_printf(m, "Pipe B fw needed: %s\n",
> 1154 str_yes_no(IS_ALDERLAKE_P(i915) ||
> 1155 DISPLAY_VER(i915) >= 14));
> 1156 seq_printf(m, "Pipe B fw loaded: %s\n",
> 1157 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEB)));
> 1158
> 1159 if (!intel_dmc_has_payload(i915))
intel_dmc_has_payload() should always return false for dmc == NULL.
BR,
Jani.
> 1160 goto out;
> 1161
> 1162 seq_printf(m, "version: %d.%d\n", DMC_VERSION_MAJOR(dmc->version),
> ^^^^^^^^^^^^
> 1163 DMC_VERSION_MINOR(dmc->version));
> ^^^^^^^^^^^^
> Unchecked dereferences.
>
> 1164
>
> regards,
> dan carpenter
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [bug report] drm/i915/dmc: add i915_to_dmc() and dmc->i915 and use them
2023-03-09 14:51 ` Jani Nikula
@ 2023-03-10 15:19 ` Dan Carpenter
2023-03-10 16:36 ` Jani Nikula
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2023-03-10 15:19 UTC (permalink / raw)
To: Jani Nikula; +Cc: intel-gfx
On Thu, Mar 09, 2023 at 04:51:10PM +0200, Jani Nikula wrote:
> On Thu, 09 Mar 2023, Dan Carpenter <error27@gmail.com> wrote:
> > Hello Jani Nikula,
> >
> > This is a semi-automatic email about new static checker warnings.
> >
> > The patch 1b28c1c789d0: "drm/i915/dmc: add i915_to_dmc() and
> > dmc->i915 and use them" from Mar 1, 2023, leads to the following
> > Smatch complaint:
> >
> > drivers/gpu/drm/i915/display/intel_dmc.c:1162 intel_dmc_debugfs_status_show()
> > error: we previously assumed 'dmc' could be null (see line 1148)
> >
> > drivers/gpu/drm/i915/display/intel_dmc.c
> > 1142
> > 1143 wakeref = intel_runtime_pm_get(&i915->runtime_pm);
> > 1144
> > 1145 seq_printf(m, "DMC initialized: %s\n", str_yes_no(dmc));'
> > ^^^^^^^^^^^^^^^
> > This is a check for NULL too.
> >
> > 1146 seq_printf(m, "fw loaded: %s\n",
> > 1147 str_yes_no(intel_dmc_has_payload(i915)));
> > 1148 seq_printf(m, "path: %s\n", dmc ? dmc->fw_path : "N/A");
> > ^^^
> > The patch adds a check for NULL.
> >
> > 1149 seq_printf(m, "Pipe A fw needed: %s\n",
> > 1150 str_yes_no(GRAPHICS_VER(i915) >= 12));
> > 1151 seq_printf(m, "Pipe A fw loaded: %s\n",
> > 1152 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEA)));
> > 1153 seq_printf(m, "Pipe B fw needed: %s\n",
> > 1154 str_yes_no(IS_ALDERLAKE_P(i915) ||
> > 1155 DISPLAY_VER(i915) >= 14));
> > 1156 seq_printf(m, "Pipe B fw loaded: %s\n",
> > 1157 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEB)));
> > 1158
> > 1159 if (!intel_dmc_has_payload(i915))
>
> intel_dmc_has_payload() should always return false for dmc == NULL.
Ah, right. Sorry for the noise. I'm going to try figure out how to
make Smatch parse this correctly.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [bug report] drm/i915/dmc: add i915_to_dmc() and dmc->i915 and use them
2023-03-10 15:19 ` Dan Carpenter
@ 2023-03-10 16:36 ` Jani Nikula
0 siblings, 0 replies; 4+ messages in thread
From: Jani Nikula @ 2023-03-10 16:36 UTC (permalink / raw)
To: Dan Carpenter; +Cc: intel-gfx
On Fri, 10 Mar 2023, Dan Carpenter <error27@gmail.com> wrote:
> On Thu, Mar 09, 2023 at 04:51:10PM +0200, Jani Nikula wrote:
>> On Thu, 09 Mar 2023, Dan Carpenter <error27@gmail.com> wrote:
>> > Hello Jani Nikula,
>> >
>> > This is a semi-automatic email about new static checker warnings.
>> >
>> > The patch 1b28c1c789d0: "drm/i915/dmc: add i915_to_dmc() and
>> > dmc->i915 and use them" from Mar 1, 2023, leads to the following
>> > Smatch complaint:
>> >
>> > drivers/gpu/drm/i915/display/intel_dmc.c:1162 intel_dmc_debugfs_status_show()
>> > error: we previously assumed 'dmc' could be null (see line 1148)
>> >
>> > drivers/gpu/drm/i915/display/intel_dmc.c
>> > 1142
>> > 1143 wakeref = intel_runtime_pm_get(&i915->runtime_pm);
>> > 1144
>> > 1145 seq_printf(m, "DMC initialized: %s\n", str_yes_no(dmc));'
>> > ^^^^^^^^^^^^^^^
>> > This is a check for NULL too.
>> >
>> > 1146 seq_printf(m, "fw loaded: %s\n",
>> > 1147 str_yes_no(intel_dmc_has_payload(i915)));
>> > 1148 seq_printf(m, "path: %s\n", dmc ? dmc->fw_path : "N/A");
>> > ^^^
>> > The patch adds a check for NULL.
>> >
>> > 1149 seq_printf(m, "Pipe A fw needed: %s\n",
>> > 1150 str_yes_no(GRAPHICS_VER(i915) >= 12));
>> > 1151 seq_printf(m, "Pipe A fw loaded: %s\n",
>> > 1152 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEA)));
>> > 1153 seq_printf(m, "Pipe B fw needed: %s\n",
>> > 1154 str_yes_no(IS_ALDERLAKE_P(i915) ||
>> > 1155 DISPLAY_VER(i915) >= 14));
>> > 1156 seq_printf(m, "Pipe B fw loaded: %s\n",
>> > 1157 str_yes_no(has_dmc_id_fw(i915, DMC_FW_PIPEB)));
>> > 1158
>> > 1159 if (!intel_dmc_has_payload(i915))
>>
>> intel_dmc_has_payload() should always return false for dmc == NULL.
>
> Ah, right. Sorry for the noise. I'm going to try figure out how to
> make Smatch parse this correctly.
No worries. I did wonder while writing the patch whether it would throw
off people, didn't even consider static analysis. :)
BR,
Jani.
--
Jani Nikula, Intel Open Source Graphics Center
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-10 16:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-09 14:46 [Intel-gfx] [bug report] drm/i915/dmc: add i915_to_dmc() and dmc->i915 and use them Dan Carpenter
2023-03-09 14:51 ` Jani Nikula
2023-03-10 15:19 ` Dan Carpenter
2023-03-10 16:36 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).