Unverified Commit 7dd4a6c1 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!9586 [sync] PR-9284: of: module: add buffer overflow check in of_modalias()

parents cac82ad9 6515a0c9
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -231,14 +231,15 @@ static ssize_t of_device_get_modalias(struct device *dev, char *str, ssize_t len
	csize = snprintf(str, len, "of:N%pOFn%c%s", dev->of_node, 'T',
			 of_node_get_device_type(dev->of_node));
	tsize = csize;
	if (csize >= len)
		csize = len > 0 ? len - 1 : 0;
	len -= csize;
	if (str)
	str += csize;

	of_property_for_each_string(dev->of_node, "compatible", p, compat) {
		csize = strlen(compat) + 1;
		tsize += csize;
		if (csize > len)
		if (csize >= len)
			continue;

		csize = snprintf(str, len, "C%s", compat);