scm.c (b74b953b998bcc2db91b694446f3a2619ec32de6) | scm.c (bba14de98753cb6599a2dae0e520714b2153522d) |
---|---|
1/* scm.c - Socket level control messages processing. 2 * 3 * Author: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 4 * Alignment and value checking mods by Craig Metz 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 65 unchanged lines hidden (view full) --- 74 75 if (!fpl) 76 { 77 fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL); 78 if (!fpl) 79 return -ENOMEM; 80 *fplp = fpl; 81 fpl->count = 0; | 1/* scm.c - Socket level control messages processing. 2 * 3 * Author: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru> 4 * Alignment and value checking mods by Craig Metz 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 65 unchanged lines hidden (view full) --- 74 75 if (!fpl) 76 { 77 fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL); 78 if (!fpl) 79 return -ENOMEM; 80 *fplp = fpl; 81 fpl->count = 0; |
82 fpl->max = SCM_MAX_FD; |
|
82 } 83 fpp = &fpl->fp[fpl->count]; 84 | 83 } 84 fpp = &fpl->fp[fpl->count]; 85 |
85 if (fpl->count + num > SCM_MAX_FD) | 86 if (fpl->count + num > fpl->max) |
86 return -EINVAL; 87 88 /* 89 * Verify the descriptors and increment the usage count. 90 */ 91 92 for (i=0; i< num; i++) 93 { --- 232 unchanged lines hidden (view full) --- 326struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl) 327{ 328 struct scm_fp_list *new_fpl; 329 int i; 330 331 if (!fpl) 332 return NULL; 333 | 87 return -EINVAL; 88 89 /* 90 * Verify the descriptors and increment the usage count. 91 */ 92 93 for (i=0; i< num; i++) 94 { --- 232 unchanged lines hidden (view full) --- 327struct scm_fp_list *scm_fp_dup(struct scm_fp_list *fpl) 328{ 329 struct scm_fp_list *new_fpl; 330 int i; 331 332 if (!fpl) 333 return NULL; 334 |
334 new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL); | 335 new_fpl = kmemdup(fpl, offsetof(struct scm_fp_list, fp[fpl->count]), 336 GFP_KERNEL); |
335 if (new_fpl) { | 337 if (new_fpl) { |
336 for (i=fpl->count-1; i>=0; i--) | 338 for (i = 0; i < fpl->count; i++) |
337 get_file(fpl->fp[i]); | 339 get_file(fpl->fp[i]); |
338 memcpy(new_fpl, fpl, sizeof(*fpl)); | 340 new_fpl->max = new_fpl->count; |
339 } 340 return new_fpl; 341} 342EXPORT_SYMBOL(scm_fp_dup); | 341 } 342 return new_fpl; 343} 344EXPORT_SYMBOL(scm_fp_dup); |