Commit a1f35c64 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

accel: check strdup()'s result in assign_opc()



Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I259d30efcf7c0b67053cac23ba73a9cc4e88bc39
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/18871


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 57c911bc
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -245,6 +245,8 @@ _accel_get_opc_name(enum accel_opcode opcode, const char **opcode_name)
int
spdk_accel_assign_opc(enum accel_opcode opcode, const char *name)
{
	char *copy;

	if (g_modules_started == true) {
		/* we don't allow re-assignment once things have started */
		return -EINVAL;
@@ -255,8 +257,13 @@ spdk_accel_assign_opc(enum accel_opcode opcode, const char *name)
		return -EINVAL;
	}

	copy = strdup(name);
	if (copy == NULL) {
		return -ENOMEM;
	}

	/* module selection will be validated after the framework starts. */
	g_modules_opc_override[opcode] = strdup(name);
	g_modules_opc_override[opcode] = copy;

	return 0;
}