提交 63c3b5d2 编写于 作者: G GONG, Ruiqi 提交者: Casey Schaufler

smack: Replace kzalloc + strncpy with kstrndup

Simplify the code by using kstrndup instead of kzalloc and strncpy in
smk_parse_smack(), which meanwhile remove strncpy as [1] suggests.

[1]: https://github.com/KSPP/linux/issues/90Signed-off-by: NGONG, Ruiqi <gongruiqi1@huawei.com>
Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
上级 f2906aa8
......@@ -465,12 +465,9 @@ char *smk_parse_smack(const char *string, int len)
if (i == 0 || i >= SMK_LONGLABEL)
return ERR_PTR(-EINVAL);
smack = kzalloc(i + 1, GFP_NOFS);
if (smack == NULL)
smack = kstrndup(string, i, GFP_NOFS);
if (!smack)
return ERR_PTR(-ENOMEM);
strncpy(smack, string, i);
return smack;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册