diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/irda/irias_object.c | 43 |
1 files changed, 5 insertions, 38 deletions
diff --git a/net/irda/irias_object.c b/net/irda/irias_object.c index 4adaae242b9e..cf302457097b 100644 --- a/net/irda/irias_object.c +++ b/net/irda/irias_object.c | |||
@@ -36,39 +36,6 @@ hashbin_t *irias_objects; | |||
36 | */ | 36 | */ |
37 | struct ias_value irias_missing = { IAS_MISSING, 0, 0, 0, {0}}; | 37 | struct ias_value irias_missing = { IAS_MISSING, 0, 0, 0, {0}}; |
38 | 38 | ||
39 | /* | ||
40 | * Function strndup (str, max) | ||
41 | * | ||
42 | * My own kernel version of strndup! | ||
43 | * | ||
44 | * Faster, check boundary... Jean II | ||
45 | */ | ||
46 | static char *strndup(char *str, size_t max) | ||
47 | { | ||
48 | char *new_str; | ||
49 | int len; | ||
50 | |||
51 | /* Check string */ | ||
52 | if (str == NULL) | ||
53 | return NULL; | ||
54 | /* Check length, truncate */ | ||
55 | len = strlen(str); | ||
56 | if(len > max) | ||
57 | len = max; | ||
58 | |||
59 | /* Allocate new string */ | ||
60 | new_str = kmalloc(len + 1, GFP_ATOMIC); | ||
61 | if (new_str == NULL) { | ||
62 | IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); | ||
63 | return NULL; | ||
64 | } | ||
65 | |||
66 | /* Copy and truncate */ | ||
67 | memcpy(new_str, str, len); | ||
68 | new_str[len] = '\0'; | ||
69 | |||
70 | return new_str; | ||
71 | } | ||
72 | 39 | ||
73 | /* | 40 | /* |
74 | * Function ias_new_object (name, id) | 41 | * Function ias_new_object (name, id) |
@@ -90,7 +57,7 @@ struct ias_object *irias_new_object( char *name, int id) | |||
90 | } | 57 | } |
91 | 58 | ||
92 | obj->magic = IAS_OBJECT_MAGIC; | 59 | obj->magic = IAS_OBJECT_MAGIC; |
93 | obj->name = strndup(name, IAS_MAX_CLASSNAME); | 60 | obj->name = kstrndup(name, IAS_MAX_CLASSNAME, GFP_ATOMIC); |
94 | if (!obj->name) { | 61 | if (!obj->name) { |
95 | IRDA_WARNING("%s(), Unable to allocate name!\n", | 62 | IRDA_WARNING("%s(), Unable to allocate name!\n", |
96 | __FUNCTION__); | 63 | __FUNCTION__); |
@@ -360,7 +327,7 @@ void irias_add_integer_attrib(struct ias_object *obj, char *name, int value, | |||
360 | } | 327 | } |
361 | 328 | ||
362 | attrib->magic = IAS_ATTRIB_MAGIC; | 329 | attrib->magic = IAS_ATTRIB_MAGIC; |
363 | attrib->name = strndup(name, IAS_MAX_ATTRIBNAME); | 330 | attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC); |
364 | 331 | ||
365 | /* Insert value */ | 332 | /* Insert value */ |
366 | attrib->value = irias_new_integer_value(value); | 333 | attrib->value = irias_new_integer_value(value); |
@@ -404,7 +371,7 @@ void irias_add_octseq_attrib(struct ias_object *obj, char *name, __u8 *octets, | |||
404 | } | 371 | } |
405 | 372 | ||
406 | attrib->magic = IAS_ATTRIB_MAGIC; | 373 | attrib->magic = IAS_ATTRIB_MAGIC; |
407 | attrib->name = strndup(name, IAS_MAX_ATTRIBNAME); | 374 | attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC); |
408 | 375 | ||
409 | attrib->value = irias_new_octseq_value( octets, len); | 376 | attrib->value = irias_new_octseq_value( octets, len); |
410 | if (!attrib->name || !attrib->value) { | 377 | if (!attrib->name || !attrib->value) { |
@@ -446,7 +413,7 @@ void irias_add_string_attrib(struct ias_object *obj, char *name, char *value, | |||
446 | } | 413 | } |
447 | 414 | ||
448 | attrib->magic = IAS_ATTRIB_MAGIC; | 415 | attrib->magic = IAS_ATTRIB_MAGIC; |
449 | attrib->name = strndup(name, IAS_MAX_ATTRIBNAME); | 416 | attrib->name = kstrndup(name, IAS_MAX_ATTRIBNAME, GFP_ATOMIC); |
450 | 417 | ||
451 | attrib->value = irias_new_string_value(value); | 418 | attrib->value = irias_new_string_value(value); |
452 | if (!attrib->name || !attrib->value) { | 419 | if (!attrib->name || !attrib->value) { |
@@ -506,7 +473,7 @@ struct ias_value *irias_new_string_value(char *string) | |||
506 | 473 | ||
507 | value->type = IAS_STRING; | 474 | value->type = IAS_STRING; |
508 | value->charset = CS_ASCII; | 475 | value->charset = CS_ASCII; |
509 | value->t.string = strndup(string, IAS_MAX_STRING); | 476 | value->t.string = kstrndup(string, IAS_MAX_STRING, GFP_ATOMIC); |
510 | if (!value->t.string) { | 477 | if (!value->t.string) { |
511 | IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); | 478 | IRDA_WARNING("%s: Unable to kmalloc!\n", __FUNCTION__); |
512 | kfree(value); | 479 | kfree(value); |