platform/x86: alienware-wmi-wmax: Improve platform profile probe
Hello Kurt Borja,
Commit 32b6372ddd43 ("platform/x86: alienware-wmi-wmax: Improve platform profile probe") from Mar 29, 2025 (linux-next), leads to the following Smatch static checker warning:
drivers/platform/x86/dell/alienware-wmi-wmax.c:1217 awcc_platform_profile_probe()
error: uninitialized symbol 'id'.
drivers/platform/x86/dell/alienware-wmi-wmax.c
1191 static int awcc_platform_profile_probe(void *drvdata, unsigned long *choices)
1192 {
1193 enum platform_profile_option profile;
1194 struct awcc_priv *priv = drvdata;
1195 enum awcc_thermal_profile mode;
1196 u8 id, offset = 0;
1197 int ret;
1198
1199 /*
1200 * Thermal profile IDs are listed last at offset
1201 * fan_count + temp_count + unknown_count
1202 */
1203 for (unsigned int i = 0; i < ARRAY_SIZE(priv->res_count) - 1; i++)
1204 offset += priv->res_count[i];
1205
1206 for (unsigned int i = 0; i < priv->profile_count; i++) {
1207 ret = awcc_op_get_resource_id(priv->wdev, i + offset, &id);
1208 if (ret == -EIO)-ENOMSG is not handled.
1209 return ret;
1210 /*
1211 * Some devices report an incorrect number of thermal profiles
1212 * so the resource ID list may end prematurely
1213 */
1214 if (ret == -EBADRQC)
1215 break;
1216
--> 1217 if (!is_awcc_thermal_profile_id(id)) {
1218 dev_dbg(&priv->wdev->dev, "Unmapped thermal profile ID 0x%02x\n", id);
1219 continue;
1220 }
1221
1222 mode = FIELD_GET(AWCC_THERMAL_MODE_MASK, id);
1223 profile = awcc_mode_to_platform_profile[mode];
1224 priv->supported_profiles[profile] = id;
1225
1226 __set_bit(profile, choices);
1227 }
1228
1229 if (bitmap_empty(choices, PLATFORM_PROFILE_LAST))
1230 return -ENODEV;
1231
1232 if (awcc->gmode) {
1233 priv->supported_profiles[PLATFORM_PROFILE_PERFORMANCE] =
1234 AWCC_SPECIAL_PROFILE_GMODE;
1235
1236 __set_bit(PLATFORM_PROFILE_PERFORMANCE, choices);
1237 }
1238
1239 /* Every model supports the "custom" profile */
1240 priv->supported_profiles[PLATFORM_PROFILE_CUSTOM] =
1241 AWCC_SPECIAL_PROFILE_CUSTOM;
1242
1243 __set_bit(PLATFORM_PROFILE_CUSTOM, choices);
1244
1245 return 0;
1246 }regards,
dan carpenter
Hi Dan,
Quoted 29 lines · Dan Carpenter
Hello Kurt Borja,
Commit
32b6372ddd43("platform/x86: alienware-wmi-wmax: Improve platform profile probe") from Mar 29, 2025 (linux-next), leads to the following Smatch static checker warning:
drivers/platform/x86/dell/alienware-wmi-wmax.c:1217awcc_platform_profile_probe()
error: uninitialized symbol 'id'.
drivers/platform/x86/dell/alienware-wmi-wmax.c1191 static int awcc_platform_profile_probe(void *drvdata, unsigned long *choices) 1192 { 1193 enum platform_profile_option profile; 1194 struct awcc_priv *priv = drvdata; 1195 enum awcc_thermal_profile mode; 1196 u8 id, offset = 0; 1197 int ret; 1198 1199 /* 1200 * Thermal profile IDs are listed last at offset 1201 * fan_count + temp_count + unknown_count 1202 */ 1203 for (unsigned int i = 0; i < ARRAY_SIZE(priv->res_count) - 1; i++) 1204 offset += priv->res_count[i]; 1205 1206 for (unsigned int i = 0; i < priv->profile_count; i++) { 1207 ret = awcc_op_get_resource_id(priv->wdev, i + offset, &id); 1208 if (ret == -EIO)
Quoted 1 line
-ENOMSGis not handled.
True.
I'll submit a fix for this. Thank you for reporting!
Signature · 1 line
~ Kurt
Quoted 42 lines
1209 return ret; 1210 /* 1211 * Some devices report an incorrect number of thermal profiles 1212 * so the resource ID list may end prematurely 1213 */ 1214 if (ret == -EBADRQC) 1215 break; 1216 --> 1217 if (!is_awcc_thermal_profile_id(id)) { 1218 dev_dbg(&priv->wdev->dev, "Unmapped thermal profile ID 0x%02x\n", id); 1219 continue; 1220 } 1221 1222 mode = FIELD_GET(AWCC_THERMAL_MODE_MASK, id); 1223 profile = awcc_mode_to_platform_profile[mode]; 1224 priv->supported_profiles[profile] = id; 1225 1226 __set_bit(profile, choices); 1227 } 1228 1229 if (bitmap_empty(choices, PLATFORM_PROFILE_LAST)) 1230 return -ENODEV; 1231 1232 if (awcc->gmode) { 1233 priv->supported_profiles[PLATFORM_PROFILE_PERFORMANCE] = 1234 AWCC_SPECIAL_PROFILE_GMODE; 1235 1236 __set_bit(PLATFORM_PROFILE_PERFORMANCE, choices); 1237 } 1238 1239 /* Every model supports the "custom" profile */ 1240 priv->supported_profiles[PLATFORM_PROFILE_CUSTOM] = 1241 AWCC_SPECIAL_PROFILE_CUSTOM; 1242 1243 __set_bit(PLATFORM_PROFILE_CUSTOM, choices); 1244 1245 return 0; 1246 }regards,
dan carpenter