Skip to content

Commit 38d4f74

Browse files
committed
media: atomisp_gmin_platform: stop abusing efivar API
As the code comment already suggests, using the efivar API in this way is not how it is intended, and so let's switch to the right one, which is simply to call efi.get_variable() directly after checking whether or not the GetVariable() runtime service is supported. Acked-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Ard Biesheuvel <[email protected]>
1 parent 416581e commit 38d4f74

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,7 +1284,7 @@ static int gmin_get_config_var(struct device *maindev,
12841284
const struct dmi_system_id *id;
12851285
struct device *dev = maindev;
12861286
char var8[CFG_VAR_NAME_MAX];
1287-
struct efivar_entry *ev;
1287+
efi_status_t status;
12881288
int i, ret;
12891289

12901290
/* For sensors, try first to use the _DSM table */
@@ -1326,33 +1326,18 @@ static int gmin_get_config_var(struct device *maindev,
13261326
for (i = 0; i < sizeof(var8) && var8[i]; i++)
13271327
var16[i] = var8[i];
13281328

1329-
/* Not sure this API usage is kosher; efivar_entry_get()'s
1330-
* implementation simply uses VariableName and VendorGuid from
1331-
* the struct and ignores the rest, but it seems like there
1332-
* ought to be an "official" efivar_entry registered
1333-
* somewhere?
1334-
*/
1335-
ev = kzalloc(sizeof(*ev), GFP_KERNEL);
1336-
if (!ev)
1337-
return -ENOMEM;
1338-
memcpy(&ev->var.VariableName, var16, sizeof(var16));
1339-
ev->var.VendorGuid = GMIN_CFG_VAR_EFI_GUID;
1340-
ev->var.DataSize = *out_len;
1341-
1342-
ret = efivar_entry_get(ev, &ev->var.Attributes,
1343-
&ev->var.DataSize, ev->var.Data);
1344-
if (ret == 0) {
1345-
memcpy(out, ev->var.Data, ev->var.DataSize);
1346-
*out_len = ev->var.DataSize;
1329+
status = EFI_UNSUPPORTED;
1330+
if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
1331+
status = efi.get_variable(var16, &GMIN_CFG_VAR_EFI_GUID, NULL,
1332+
(unsigned long *)out_len, out);
1333+
if (status == EFI_SUCCESS) {
13471334
dev_info(maindev, "found EFI entry for '%s'\n", var8);
13481335
} else if (is_gmin) {
13491336
dev_info(maindev, "Failed to find EFI gmin variable %s\n", var8);
13501337
} else {
13511338
dev_info(maindev, "Failed to find EFI variable %s\n", var8);
13521339
}
13531340

1354-
kfree(ev);
1355-
13561341
return ret;
13571342
}
13581343

0 commit comments

Comments
 (0)