mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
libceph, ceph: avoid memory leak when specifying same option several times
When parsing string option, in order to avoid memory leak we need to carefully free it first in case of specifying same option several times. Signed-off-by: Chengguang Xu <[email protected]> Reviewed-by: Ilya Dryomov <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
This commit is contained in:
parent
6ef0bc6dde
commit
937441f3a3
2 changed files with 9 additions and 0 deletions
|
|
@ -418,6 +418,7 @@ ceph_parse_options(char *options, const char *dev_name,
|
|||
opt->flags |= CEPH_OPT_FSID;
|
||||
break;
|
||||
case Opt_name:
|
||||
kfree(opt->name);
|
||||
opt->name = kstrndup(argstr[0].from,
|
||||
argstr[0].to-argstr[0].from,
|
||||
GFP_KERNEL);
|
||||
|
|
@ -427,6 +428,9 @@ ceph_parse_options(char *options, const char *dev_name,
|
|||
}
|
||||
break;
|
||||
case Opt_secret:
|
||||
ceph_crypto_key_destroy(opt->key);
|
||||
kfree(opt->key);
|
||||
|
||||
opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
|
||||
if (!opt->key) {
|
||||
err = -ENOMEM;
|
||||
|
|
@ -437,6 +441,9 @@ ceph_parse_options(char *options, const char *dev_name,
|
|||
goto out;
|
||||
break;
|
||||
case Opt_key:
|
||||
ceph_crypto_key_destroy(opt->key);
|
||||
kfree(opt->key);
|
||||
|
||||
opt->key = kzalloc(sizeof(*opt->key), GFP_KERNEL);
|
||||
if (!opt->key) {
|
||||
err = -ENOMEM;
|
||||
|
|
|
|||
Loading…
Reference in a new issue