Re: [PATCH] cgroup/rdma: fix strncmp prefix match in parse_resource()

Michal Koutný
2026-04-15T13:37:31Z

[-- Attachment #1: Type: text/plain, Size: 515 bytes --]

Hello.

On Tue, Apr 14, 2026 at 10:09:36AM +0800, cuitao <cuitao@kylinos.cn> wrote:
> }
> - if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
> + if (strcmp(value, RDMACG_MAX_STR) == 0) {

Have you tested this? (When 'max' isn't the last assignment.)

That value/c string is taken out of the whole line (see
rdmacg_parse_limits), so it wouldn't be necessarily equal to
RDMACG_MAX_STR. So bounded compare is still somewhat needed:

if (strncmp(value, RDMACG_MAX_STR, strlen(RDMACG_MAX_STR)) == 0) {

Thanks,
Michal

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]