Using uninitialized variables leads to undefined behavior.
Moreover, it causes the compiler to complain with:
../drivers/gpu/drm/xe/xe_vm.c:3265:40: error: variable 'vma' is uninitialized when used here [-Werror,-Wuninitialized]
../drivers/gpu/drm/xe/xe_rtp.c:118:36: error: variable 'i' is uninitialized when used here [-Werror,-Wuninitialized]
../drivers/gpu/drm/xe/xe_mocs.c:449:3: error: variable 'flags' is uninitialized when used here [-Werror,-Wuninitialized]
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Link: https://lore.kernel.org/r/20230523135020.345596-1-michal@hardline.pl
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
static unsigned int get_mocs_settings(struct xe_device *xe,
struct xe_mocs_info *info)
{
- unsigned int flags;
+ unsigned int flags = 0;
memset(info, 0, sizeof(struct xe_mocs_info));
if (!rule_matches(xe, gt, hwe, entry->rules, entry->n_rules))
return false;
- for (action = &entry->actions[0]; i < entry->n_actions; action++, i++) {
+ for (i = 0, action = &entry->actions[0]; i < entry->n_actions; action++, i++) {
if ((entry->flags & XE_RTP_ENTRY_FLAG_FOREACH_ENGINE) ||
(action->flags & XE_RTP_ACTION_FLAG_ENGINE_BASE))
mmio_base = hwe->mmio_base;
if (!vmas[i])
break;
- list_for_each_entry_safe(vma, next, &vma->unbind_link,
+ list_for_each_entry_safe(vma, next, &vmas[i]->unbind_link,
unbind_link) {
list_del_init(&vma->unbind_link);
if (!vma->destroyed) {