Print this page
11927 Log, or optionally panic, on zero-length kmem allocations
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/os/smb_subr.c
+++ new/usr/src/uts/common/os/smb_subr.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
|
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22
23 23 /*
24 24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 27
28 -#pragma ident "%Z%%M% %I% %E% SMI"
28 +/*
29 + * Copyright (c) 2015 Joyent, Inc. All rights reserved.
30 + */
29 31
30 32 #include <sys/smbios_impl.h>
31 33 #include <sys/cmn_err.h>
32 34 #include <sys/varargs.h>
33 35 #include <sys/systm.h>
34 36 #include <sys/kmem.h>
35 37
36 38 /*ARGSUSED*/
37 39 const char *
38 40 smb_strerror(int err)
39 41 {
40 42 return (NULL);
41 43 }
42 44
43 45 void *
44 46 smb_alloc(size_t len)
45 47 {
46 - return (kmem_alloc(len, KM_SLEEP));
48 + return (len > 0 ? kmem_alloc(len, KM_SLEEP) : NULL);
47 49 }
48 50
49 51 void *
50 52 smb_zalloc(size_t len)
51 53 {
52 - return (kmem_zalloc(len, KM_SLEEP));
54 + return (len > 0 ? kmem_zalloc(len, KM_SLEEP) : NULL);
53 55 }
54 56
55 57 void
56 58 smb_free(void *buf, size_t len)
57 59 {
58 60 kmem_free(buf, len);
59 61 }
60 62
61 63 /*PRINTFLIKE2*/
62 64 void
63 65 smb_dprintf(smbios_hdl_t *shp, const char *format, ...)
64 66 {
65 67 va_list ap;
66 68
67 69 if (!(shp->sh_flags & SMB_FL_DEBUG))
68 70 return;
69 71
70 72 va_start(ap, format);
71 73 vcmn_err(CE_CONT, format, ap);
72 74 va_end(ap);
73 75 }
|
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX