[bug report] platform/x86: hp-wmi: Fix platform profile option switch bug on Omen and Victus laptops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Alexis Belmonte,

Commit d23430233494 ("platform/x86: hp-wmi: Fix platform profile
option switch bug on Omen and Victus laptops") from Jul 8, 2024
(linux-next), leads to the following Smatch static checker warning:

	drivers/acpi/platform_profile.c:161 platform_profile_cycle()
	error: uninitialized symbol 'profile'.

drivers/acpi/platform_profile.c
    151                 return -ENODEV;
    152         }
    153 
    154         err = cur_profile->profile_get(cur_profile, &profile);
                                                            ^^^^^^^^
Profile is supposed to be initialized here.

    155         if (err) {
    156                 mutex_unlock(&profile_lock);
    157                 return err;
    158         }
    159 
    160         next = find_next_bit_wrap(cur_profile->choices, PLATFORM_PROFILE_LAST,
--> 161                                   profile + 1);
    162 
    163         if (WARN_ON(next == PLATFORM_PROFILE_LAST)) {
    164                 mutex_unlock(&profile_lock);
    165                 return -EINVAL;
    166         }
    167 
    168         err = cur_profile->profile_set(cur_profile, next);
    169         mutex_unlock(&profile_lock);
    170 
    171         if (!err)
    172                 sysfs_notify(acpi_kobj, NULL, "platform_profile");
    173 
    174         return err;
    175 }

drivers/platform/x86/hp/hp-wmi.c
  1238  static int platform_profile_omen_get(struct platform_profile_handler *pprof,
  1239                                       enum platform_profile_option *profile)
  1240  {
  1241          enum platform_profile_option selected_platform_profile;
  1242  
  1243          /*
  1244           * We directly return the stored platform profile, as the embedded
  1245           * controller will not accept switching to the performance option when
  1246           * the conditions are not met (e.g. the laptop is not plugged in).
  1247           *
  1248           * If we directly return what the EC reports, the platform profile will
  1249           * immediately "switch back" to normal mode, which is against the
  1250           * expected behaviour from a userspace point of view, as described in
  1251           * the Platform Profile Section page of the kernel documentation.
  1252           *
  1253           * See also omen_powersource_event.
  1254           */
  1255          guard(mutex)(&active_platform_profile_lock);
  1256          selected_platform_profile = active_platform_profile;
  1257  
  1258          return selected_platform_profile;

This function implements cur_profile->profile_get() but:
1) It doesn't set *profile
2) It is supposed to return zero instead of selected_platform_profile

  1259  }

regards,
dan carpenter




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux