Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-drm-fsl-dcu.git] / net / sunrpc / auth_gss / gss_mech_switch.c
index b048bf672da2bbffbe35953b3e47a57b7e2383d3..3423890e4a30718eed9f00780f5752188d0186f1 100644 (file)
@@ -6,14 +6,14 @@
  *
  *  J. Bruce Fields   <bfields@umich.edu>
  *
- *  Redistribution and use in source and binary forms, with or without 
+ *  Redistribution and use in source and binary forms, with or without
  *  modification, are permitted provided that the following conditions
  *  are met:
  *
  *  1. Redistributions of source code must retain the above copyright
  *     notice, this list of conditions and the following disclaimer.
  *  2. Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the 
+ *     notice, this list of conditions and the following disclaimer in the
  *     documentation and/or other materials provided with the distribution.
  *  3. Neither the name of the University nor the names of its
  *     contributors may be used to endorse or promote products derived
@@ -60,8 +60,7 @@ gss_mech_free(struct gss_api_mech *gm)
 
        for (i = 0; i < gm->gm_pf_num; i++) {
                pf = &gm->gm_pfs[i];
-               if (pf->auth_domain_name)
-                       kfree(pf->auth_domain_name);
+               kfree(pf->auth_domain_name);
                pf->auth_domain_name = NULL;
        }
 }
@@ -225,7 +224,8 @@ EXPORT_SYMBOL(gss_service_to_auth_domain_name);
 void
 gss_mech_put(struct gss_api_mech * gm)
 {
-       module_put(gm->gm_owner);
+       if (gm)
+               module_put(gm->gm_owner);
 }
 
 EXPORT_SYMBOL(gss_mech_put);
@@ -237,9 +237,8 @@ gss_import_sec_context(const void *input_token, size_t bufsize,
                       struct gss_api_mech      *mech,
                       struct gss_ctx           **ctx_id)
 {
-       if (!(*ctx_id = kmalloc(sizeof(**ctx_id), GFP_KERNEL)))
+       if (!(*ctx_id = kzalloc(sizeof(**ctx_id), GFP_KERNEL)))
                return GSS_S_FAILURE;
-       memset(*ctx_id, 0, sizeof(**ctx_id));
        (*ctx_id)->mech_type = gss_mech_get(mech);
 
        return mech->gm_ops
@@ -308,8 +307,7 @@ gss_delete_sec_context(struct gss_ctx       **context_handle)
                (*context_handle)->mech_type->gm_ops
                        ->gss_delete_sec_context((*context_handle)
                                                        ->internal_ctx_id);
-       if ((*context_handle)->mech_type)
-               gss_mech_put((*context_handle)->mech_type);
+       gss_mech_put((*context_handle)->mech_type);
        kfree(*context_handle);
        *context_handle=NULL;
        return GSS_S_COMPLETE;