Skip to content

Commit 90f6339

Browse files
lxingregkh
authored andcommitted
sctp: allocate sctp_sockaddr_entry with kzalloc
commit 400b8b9 upstream. The similar issue as fixed in Commit 4a2eb0c ("sctp: initialize sin6_flowinfo for ipv6 addrs in sctp_inet6addr_event") also exists in sctp_inetaddr_event, as Alexander noticed. To fix it, allocate sctp_sockaddr_entry with kzalloc for both sctp ipv4 and ipv6 addresses, as does in sctp_v4/6_copy_addrlist(). Reported-by: Alexander Potapenko <[email protected]> Signed-off-by: Xin Long <[email protected]> Reported-by: [email protected] Acked-by: Marcelo Ricardo Leitner <[email protected]> Acked-by: Neil Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 00199a4 commit 90f6339

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

net/sctp/ipv6.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,9 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
9797

9898
switch (ev) {
9999
case NETDEV_UP:
100-
addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
100+
addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
101101
if (addr) {
102102
addr->a.v6.sin6_family = AF_INET6;
103-
addr->a.v6.sin6_port = 0;
104-
addr->a.v6.sin6_flowinfo = 0;
105103
addr->a.v6.sin6_addr = ifa->addr;
106104
addr->a.v6.sin6_scope_id = ifa->idev->dev->ifindex;
107105
addr->valid = 1;
@@ -431,7 +429,6 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
431429
addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
432430
if (addr) {
433431
addr->a.v6.sin6_family = AF_INET6;
434-
addr->a.v6.sin6_port = 0;
435432
addr->a.v6.sin6_addr = ifp->addr;
436433
addr->a.v6.sin6_scope_id = dev->ifindex;
437434
addr->valid = 1;

net/sctp/protocol.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
101101
addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
102102
if (addr) {
103103
addr->a.v4.sin_family = AF_INET;
104-
addr->a.v4.sin_port = 0;
105104
addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
106105
addr->valid = 1;
107106
INIT_LIST_HEAD(&addr->list);
@@ -776,10 +775,9 @@ static int sctp_inetaddr_event(struct notifier_block *this, unsigned long ev,
776775

777776
switch (ev) {
778777
case NETDEV_UP:
779-
addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
778+
addr = kzalloc(sizeof(*addr), GFP_ATOMIC);
780779
if (addr) {
781780
addr->a.v4.sin_family = AF_INET;
782-
addr->a.v4.sin_port = 0;
783781
addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
784782
addr->valid = 1;
785783
spin_lock_bh(&net->sctp.local_addr_lock);

0 commit comments

Comments
 (0)