Commit 38d4f74b authored by Ard Biesheuvel's avatar Ard Biesheuvel
Browse files

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: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 416581e4
Loading
Loading
Loading
Loading
+6 −21
Original line number Original line Diff line number Diff line
@@ -1284,7 +1284,7 @@ static int gmin_get_config_var(struct device *maindev,
	const struct dmi_system_id *id;
	const struct dmi_system_id *id;
	struct device *dev = maindev;
	struct device *dev = maindev;
	char var8[CFG_VAR_NAME_MAX];
	char var8[CFG_VAR_NAME_MAX];
	struct efivar_entry *ev;
	efi_status_t status;
	int i, ret;
	int i, ret;


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


	/* Not sure this API usage is kosher; efivar_entry_get()'s
	status = EFI_UNSUPPORTED;
	 * implementation simply uses VariableName and VendorGuid from
	if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE))
	 * the struct and ignores the rest, but it seems like there
		status = efi.get_variable(var16, &GMIN_CFG_VAR_EFI_GUID, NULL,
	 * ought to be an "official" efivar_entry registered
					  (unsigned long *)out_len, out);
	 * somewhere?
	if (status == EFI_SUCCESS) {
	 */
	ev = kzalloc(sizeof(*ev), GFP_KERNEL);
	if (!ev)
		return -ENOMEM;
	memcpy(&ev->var.VariableName, var16, sizeof(var16));
	ev->var.VendorGuid = GMIN_CFG_VAR_EFI_GUID;
	ev->var.DataSize = *out_len;

	ret = efivar_entry_get(ev, &ev->var.Attributes,
			       &ev->var.DataSize, ev->var.Data);
	if (ret == 0) {
		memcpy(out, ev->var.Data, ev->var.DataSize);
		*out_len = ev->var.DataSize;
		dev_info(maindev, "found EFI entry for '%s'\n", var8);
		dev_info(maindev, "found EFI entry for '%s'\n", var8);
	} else if (is_gmin) {
	} else if (is_gmin) {
		dev_info(maindev, "Failed to find EFI gmin variable %s\n", var8);
		dev_info(maindev, "Failed to find EFI gmin variable %s\n", var8);
@@ -1351,8 +1338,6 @@ static int gmin_get_config_var(struct device *maindev,
		dev_info(maindev, "Failed to find EFI variable %s\n", var8);
		dev_info(maindev, "Failed to find EFI variable %s\n", var8);
	}
	}


	kfree(ev);

	return ret;
	return ret;
}
}