/* * netsniff-ng - the packet sniffing beast * Copyright 2009, 2010 Daniel Borkmann. * Copyright 2014 Tobias Klauser * Subject to the GPL, version 2. */ #include #include "hash.h" #include "str.h" #include "lookup.h" #include "xmalloc.h" static struct hash_table lookup_port_tables[PORTS_MAX]; static const char * const lookup_port_files[] = { [PORTS_UDP] = ETCDIRE_STRING "/udp.conf", [PORTS_TCP] = ETCDIRE_STRING "/tcp.conf", [PORTS_ETHER] = ETCDIRE_STRING "/ether.conf", }; struct port { unsigned int id; char *port; struct port *next; }; void lookup_init_ports(enum ports which) { FILE *fp; char buff[128], *ptr, *end; const char *file; struct hash_table *table; struct port *p; void **pos; bug_on(which >= PORTS_MAX); table = &lookup_port_tables[which]; file = lookup_port_files[which]; fp = fopen(file, "r"); if (!fp) panic("No %s found!\n", file); memset(buff, 0, sizeof(buff)); while (fgets(buff, sizeof(buff), fp) != NULL) { buff[sizeof(buff) - 1] = 0; ptr = buff; p = xmalloc(sizeof(*p)); p->id = strtol(ptr, &end, 0); /* not a valid line, skip */ if (p->id == 0 && end == ptr) { xfree(p); continue; } ptr = strstr(buff, ", "); /* likewise */ if (!ptr) { xfree(p); continue; } ptr += strlen(", "); ptr = strtrim_right(ptr, '\n'); ptr = strtrim_right(ptr, ' '); p->port = xstrdup(ptr); p->next = NULL; pos = insert_hash(p->id, p, table); if (pos) { p->next = *pos; *pos = p; } memset(buff, 0, sizeof(buff)); } fclose(fp); } static int __lookup_cleanup_single(void *ptr) { struct port *tmp, *p = ptr; if (!ptr) return 0; while ((tmp = p->next)) { xfree(p->port); xfree(p); p = tmp; } xfree(p->port); xfree(p); return 0; } void lookup_cleanup_ports(enum ports which) { struct hash_table *table; bug_on(which >= PORTS_MAX); table = &lookup_port_tables[which]; for_each_hash(table, __lookup_cleanup_single); free_hash(table); } #define __do_lookup_inline(id, struct_name, hash_ptr, struct_member) \ ({ \ struct struct_name *entry = lookup_hash(id, hash_ptr); \ \ while (entry && id != entry->id) \ entry = entry->next; \ \ (entry && id == entry->id ? entry->struct_member : NULL); \ }) char *lookup_ether_type(unsigned int id) { return __do_lookup_inline(id, port, &lookup_port_tables[PORTS_ETHER], port); } char *lookup_port_udp(unsigned int id) { return __do_lookup_inline(id, port, &lookup_port_tables[PORTS_UDP], port); } char *lookup_port_tcp(unsigned int id) { return __do_lookup_inline(id, port, &lookup_port_tables[PORTS_TCP], port); } -next.git/commit/?id=f139f97878039f9a49db6cb555d95f6b6e9ba0f8'>root/.mailmap
diff options
context:
space:
mode:
authorStanimir Varbanov <stanimir.varbanov@linaro.org>2016-04-11 11:38:38 +0300
committerVinod Koul <vinod.koul@intel.com>2016-04-19 21:11:31 +0530
commitf139f97878039f9a49db6cb555d95f6b6e9ba0f8 (patch)
tree98016edd494b20a2a0376ef6b66d9249884628a9 /.mailmap
parentf55532a0c0b8bb6148f4e07853b876ef73bc69ca (diff)
dmaengine: qcom: bam_dma: fix dma free memory on remove
Building the driver as a module and when removing the already inserted module gives below: [ 1389.392788] Unable to handle kernel paging request at virtual address ffffffbdc000001c [ 1389.421321] pgd = ffffffc02fa87000 [ 1389.447899] [ffffffbdc000001c] *pgd=0000000000000000, *pud=0000000000000000 [ 1389.460142] Internal error: Oops: 96000006 [#1] PREEMPT SMP [ 1389.466963] Modules linked in: qcom_bam_dma(-) [ 1389.486608] CPU: 2 PID: 2442 Comm: rmmod Not tainted 4.2.0+ #407 [ 1389.493885] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 1389.501196] task: ffffffc035bae2c0 ti: ffffffc0368a8000 task.ti: ffffffc0368a8000 [ 1389.508566] PC is at __free_pages+0xc/0x40 [ 1389.515893] LR is at free_pages.part.93+0x30/0x38 [ 1389.523141] pc : [<ffffffc00016180c>] lr : [<ffffffc00016197c>] pstate: 80000145 [ 1389.530602] sp : ffffffc0368abc20 [ 1389.537931] x29: ffffffc0368abc20 x28: ffffffc0368a8000 [ 1389.549153] x27: 0000000000000000 x26: 0000000000000000 [ 1389.560412] x25: ffffffc000cb2000 x24: 0000000000000170 [ 1389.571530] x23: 0000000000000004 x22: ffffffc036bc5010 [ 1389.582721] x21: ffffffc036bc5010 x20: 0000000000000000 [ 1389.593981] x19: 0000000000000002 x18: 0000007fcbc8e8b0 [ 1389.605301] x17: 0000007f9b8226ec x16: ffffffc0002089e8 [ 1389.616647] x15: 0000007f9b8a0588 x14: 0ffffffffffffffc [ 1389.628039] x13: 0000000000000030 x12: 0000000000000000 [ 1389.639436] x11: 0000000000000008 x10: ffffffc000ecc000 [ 1389.650872] x9 : ffffffc035bae2c0 x8 : ffffffc035bae9a8 [ 1389.662367] x7 : ffffffc035bae9a0 x6 : 0000000000000000 [ 1389.673906] x5 : ffffffbdc000001c x4 : 0000000080000000 [ 1389.685475] x3 : ffffffbdc0000000 x2 : 0000004080000000 [ 1389.697049] x1 : 0000000000000003 x0 : ffffffbdc0000000 The memory has been already freed by bam_free_chan() so fix this by skiping already freed memory. Signed-off-by: Stanimir Varbanov <stanimir.varbanov@linaro.org> Reviewed-by: Andy Gross <andy.gross@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to '.mailmap')