Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
authorNiranjan Dighe <ndighe@visteon.com>
Sun, 31 May 2015 05:39:07 +0000 (05:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 06:33:43 +0000 (15:33 +0900)
Replace kzalloc followed by memcpy by kmemdup. This patch was generated
by 'make coccicheck'

Signed-off-by: Niranjan Dighe <ndighe@visteon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/obd_config.c

index 19d4eb045b1b890de61bcdeebab7676b653e987f..fbdb748a36b9e2f45c0b7b40f0ec06c0fd404f55 100644 (file)
@@ -840,29 +840,26 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
        INIT_LIST_HEAD(&lprof->lp_list);
 
        LASSERT(proflen == (strlen(prof) + 1));
-       lprof->lp_profile = kzalloc(proflen, GFP_NOFS);
+       lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS);
        if (lprof->lp_profile == NULL) {
                err = -ENOMEM;
                goto free_lprof;
        }
-       memcpy(lprof->lp_profile, prof, proflen);
 
        LASSERT(osclen == (strlen(osc) + 1));
-       lprof->lp_dt = kzalloc(osclen, GFP_NOFS);
+       lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS);
        if (lprof->lp_dt == NULL) {
                err = -ENOMEM;
                goto free_lp_profile;
        }
-       memcpy(lprof->lp_dt, osc, osclen);
 
        if (mdclen > 0) {
                LASSERT(mdclen == (strlen(mdc) + 1));
-               lprof->lp_md = kzalloc(mdclen, GFP_NOFS);
+               lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS);
                if (lprof->lp_md == NULL) {
                        err = -ENOMEM;
                        goto free_lp_dt;
                }
-               memcpy(lprof->lp_md, mdc, mdclen);
        }
 
        list_add(&lprof->lp_list, &lustre_profile_list);