drm/tests: hdmi: Fix memory leaks in drm_display_mode_from_cea_vic()
[drm/drm-misc.git] / net / sunrpc / auth_gss / auth_gss_internal.h
blob4ebc1b7043d91740c57129ad6961056405b59355
1 // SPDX-License-Identifier: BSD-3-Clause
2 /*
3 * linux/net/sunrpc/auth_gss/auth_gss_internal.h
5 * Internal definitions for RPCSEC_GSS client authentication
7 * Copyright (c) 2000 The Regents of the University of Michigan.
8 * All rights reserved.
11 #include <linux/err.h>
12 #include <linux/string.h>
13 #include <linux/sunrpc/xdr.h>
15 static inline const void *
16 simple_get_bytes(const void *p, const void *end, void *res, size_t len)
18 const void *q = (const void *)((const char *)p + len);
19 if (unlikely(q > end || q < p))
20 return ERR_PTR(-EFAULT);
21 memcpy(res, p, len);
22 return q;
25 static inline const void *
26 simple_get_netobj_noprof(const void *p, const void *end, struct xdr_netobj *dest)
28 const void *q;
29 unsigned int len;
31 p = simple_get_bytes(p, end, &len, sizeof(len));
32 if (IS_ERR(p))
33 return p;
34 q = (const void *)((const char *)p + len);
35 if (unlikely(q > end || q < p))
36 return ERR_PTR(-EFAULT);
37 if (len) {
38 dest->data = kmemdup_noprof(p, len, GFP_KERNEL);
39 if (unlikely(dest->data == NULL))
40 return ERR_PTR(-ENOMEM);
41 } else
42 dest->data = NULL;
43 dest->len = len;
44 return q;
47 #define simple_get_netobj(...) alloc_hooks(simple_get_netobj_noprof(__VA_ARGS__))