aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-01-04 16:55:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2011-01-04 16:55:49 -0500
commit65f42886e24be2197b1263f138eabf40c6774d00 (patch)
treec45ab3a3634a9a949f54b7ee4ca9295db5674e5e
parent8a87694ed159d7abd2c9ed657416696c05db2252 (diff)
parent9fc3bbb4a752f108cf096d96640f3b548bbbce6c (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6: ipv4/route.c: respect prefsrc for local routes bridge: stp: ensure mac header is set bridge: fix br_multicast_ipv6_rcv for paged skbs atl1: fix oops when changing tx/rx ring params drivers/atm/atmtcp.c: add missing atm_dev_put starfire: Fix dma_addr_t size test for MIPS tg3: fix return value check in tg3_read_vpd() Broadcom CNIC core network driver: fix mem leak on allocation failures in cnic_alloc_uio_rings() ISDN, Gigaset: Fix memory leak in do_disconnect_req() CAN: Use inode instead of kernel address for /proc file skfp: testing the wrong variable in skfp_driver_init() ppp: allow disabling multilink protocol ID compression ehea: Avoid changing vlan flags ueagle-atm: fix PHY signal initialization race
-rw-r--r--drivers/atm/atmtcp.c5
-rw-r--r--drivers/isdn/gigaset/capi.c1
-rw-r--r--drivers/net/atlx/atl1.c10
-rw-r--r--drivers/net/cnic.c10
-rw-r--r--drivers/net/ehea/ehea_ethtool.c7
-rw-r--r--drivers/net/ppp_generic.c9
-rw-r--r--drivers/net/skfp/skfddi.c2
-rw-r--r--drivers/net/starfire.c2
-rw-r--r--drivers/net/tg3.c2
-rw-r--r--drivers/usb/atm/ueagle-atm.c22
-rw-r--r--net/bridge/br_multicast.c28
-rw-r--r--net/bridge/br_stp_bpdu.c2
-rw-r--r--net/can/bcm.c4
-rw-r--r--net/ipv4/route.c8
14 files changed, 87 insertions, 25 deletions
diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
index 2b464b631f22..0b0625054a87 100644
--- a/drivers/atm/atmtcp.c
+++ b/drivers/atm/atmtcp.c
@@ -392,7 +392,10 @@ static int atmtcp_attach(struct atm_vcc *vcc,int itf)
392 atm_dev_put(dev); 392 atm_dev_put(dev);
393 return -EMEDIUMTYPE; 393 return -EMEDIUMTYPE;
394 } 394 }
395 if (PRIV(dev)->vcc) return -EBUSY; 395 if (PRIV(dev)->vcc) {
396 atm_dev_put(dev);
397 return -EBUSY;
398 }
396 } 399 }
397 else { 400 else {
398 int error; 401 int error;
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index bcc174e4f3b1..658e75f18d05 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -1900,6 +1900,7 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,
1900 if (b3skb == NULL) { 1900 if (b3skb == NULL) {
1901 dev_err(cs->dev, "%s: out of memory\n", __func__); 1901 dev_err(cs->dev, "%s: out of memory\n", __func__);
1902 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR); 1902 send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
1903 kfree(b3cmsg);
1903 return; 1904 return;
1904 } 1905 }
1905 capi_cmsg2message(b3cmsg, 1906 capi_cmsg2message(b3cmsg,
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 53363108994e..3acf5123a6ef 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -3504,6 +3504,8 @@ static int atl1_set_ringparam(struct net_device *netdev,
3504 struct atl1_rfd_ring rfd_old, rfd_new; 3504 struct atl1_rfd_ring rfd_old, rfd_new;
3505 struct atl1_rrd_ring rrd_old, rrd_new; 3505 struct atl1_rrd_ring rrd_old, rrd_new;
3506 struct atl1_ring_header rhdr_old, rhdr_new; 3506 struct atl1_ring_header rhdr_old, rhdr_new;
3507 struct atl1_smb smb;
3508 struct atl1_cmb cmb;
3507 int err; 3509 int err;
3508 3510
3509 tpd_old = adapter->tpd_ring; 3511 tpd_old = adapter->tpd_ring;
@@ -3544,11 +3546,19 @@ static int atl1_set_ringparam(struct net_device *netdev,
3544 adapter->rrd_ring = rrd_old; 3546 adapter->rrd_ring = rrd_old;
3545 adapter->tpd_ring = tpd_old; 3547 adapter->tpd_ring = tpd_old;
3546 adapter->ring_header = rhdr_old; 3548 adapter->ring_header = rhdr_old;
3549 /*
3550 * Save SMB and CMB, since atl1_free_ring_resources
3551 * will clear them.
3552 */
3553 smb = adapter->smb;
3554 cmb = adapter->cmb;
3547 atl1_free_ring_resources(adapter); 3555 atl1_free_ring_resources(adapter);
3548 adapter->rfd_ring = rfd_new; 3556 adapter->rfd_ring = rfd_new;
3549 adapter->rrd_ring = rrd_new; 3557 adapter->rrd_ring = rrd_new;
3550 adapter->tpd_ring = tpd_new; 3558 adapter->tpd_ring = tpd_new;
3551 adapter->ring_header = rhdr_new; 3559 adapter->ring_header = rhdr_new;
3560 adapter->smb = smb;
3561 adapter->cmb = cmb;
3552 3562
3553 err = atl1_up(adapter); 3563 err = atl1_up(adapter);
3554 if (err) 3564 if (err)
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 92bac19ad60a..6dff32196c92 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -940,7 +940,7 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages)
940 &udev->l2_ring_map, 940 &udev->l2_ring_map,
941 GFP_KERNEL | __GFP_COMP); 941 GFP_KERNEL | __GFP_COMP);
942 if (!udev->l2_ring) 942 if (!udev->l2_ring)
943 return -ENOMEM; 943 goto err_udev;
944 944
945 udev->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size; 945 udev->l2_buf_size = (cp->l2_rx_ring_size + 1) * cp->l2_single_buf_size;
946 udev->l2_buf_size = PAGE_ALIGN(udev->l2_buf_size); 946 udev->l2_buf_size = PAGE_ALIGN(udev->l2_buf_size);
@@ -948,7 +948,7 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages)
948 &udev->l2_buf_map, 948 &udev->l2_buf_map,
949 GFP_KERNEL | __GFP_COMP); 949 GFP_KERNEL | __GFP_COMP);
950 if (!udev->l2_buf) 950 if (!udev->l2_buf)
951 return -ENOMEM; 951 goto err_dma;
952 952
953 write_lock(&cnic_dev_lock); 953 write_lock(&cnic_dev_lock);
954 list_add(&udev->list, &cnic_udev_list); 954 list_add(&udev->list, &cnic_udev_list);
@@ -959,6 +959,12 @@ static int cnic_alloc_uio_rings(struct cnic_dev *dev, int pages)
959 cp->udev = udev; 959 cp->udev = udev;
960 960
961 return 0; 961 return 0;
962 err_dma:
963 dma_free_coherent(&udev->pdev->dev, udev->l2_ring_size,
964 udev->l2_ring, udev->l2_ring_map);
965 err_udev:
966 kfree(udev);
967 return -ENOMEM;
962} 968}
963 969
964static int cnic_init_uio(struct cnic_dev *dev) 970static int cnic_init_uio(struct cnic_dev *dev)
diff --git a/drivers/net/ehea/ehea_ethtool.c b/drivers/net/ehea/ehea_ethtool.c
index 1f37ee6b2a26..d6cf502906cf 100644
--- a/drivers/net/ehea/ehea_ethtool.c
+++ b/drivers/net/ehea/ehea_ethtool.c
@@ -263,6 +263,13 @@ static void ehea_get_ethtool_stats(struct net_device *dev,
263 263
264static int ehea_set_flags(struct net_device *dev, u32 data) 264static int ehea_set_flags(struct net_device *dev, u32 data)
265{ 265{
266 /* Avoid changing the VLAN flags */
267 if ((data & (ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN)) !=
268 (ethtool_op_get_flags(dev) & (ETH_FLAG_RXVLAN |
269 ETH_FLAG_TXVLAN))){
270 return -EINVAL;
271 }
272
266 return ethtool_op_set_flags(dev, data, ETH_FLAG_LRO 273 return ethtool_op_set_flags(dev, data, ETH_FLAG_LRO
267 | ETH_FLAG_TXVLAN 274 | ETH_FLAG_TXVLAN
268 | ETH_FLAG_RXVLAN); 275 | ETH_FLAG_RXVLAN);
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 39659976a1ac..89294b43c4a9 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1285,6 +1285,11 @@ ppp_push(struct ppp *ppp)
1285} 1285}
1286 1286
1287#ifdef CONFIG_PPP_MULTILINK 1287#ifdef CONFIG_PPP_MULTILINK
1288static bool mp_protocol_compress __read_mostly = true;
1289module_param(mp_protocol_compress, bool, S_IRUGO | S_IWUSR);
1290MODULE_PARM_DESC(mp_protocol_compress,
1291 "compress protocol id in multilink fragments");
1292
1288/* 1293/*
1289 * Divide a packet to be transmitted into fragments and 1294 * Divide a packet to be transmitted into fragments and
1290 * send them out the individual links. 1295 * send them out the individual links.
@@ -1347,10 +1352,10 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1347 if (nfree == 0 || nfree < navail / 2) 1352 if (nfree == 0 || nfree < navail / 2)
1348 return 0; /* can't take now, leave it in xmit_pending */ 1353 return 0; /* can't take now, leave it in xmit_pending */
1349 1354
1350 /* Do protocol field compression (XXX this should be optional) */ 1355 /* Do protocol field compression */
1351 p = skb->data; 1356 p = skb->data;
1352 len = skb->len; 1357 len = skb->len;
1353 if (*p == 0) { 1358 if (*p == 0 && mp_protocol_compress) {
1354 ++p; 1359 ++p;
1355 --len; 1360 --len;
1356 } 1361 }
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index 0a66fed52e8e..16c62659cdd9 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -412,7 +412,7 @@ static int skfp_driver_init(struct net_device *dev)
412 bp->SharedMemAddr = pci_alloc_consistent(&bp->pdev, 412 bp->SharedMemAddr = pci_alloc_consistent(&bp->pdev,
413 bp->SharedMemSize, 413 bp->SharedMemSize,
414 &bp->SharedMemDMA); 414 &bp->SharedMemDMA);
415 if (!bp->SharedMemSize) { 415 if (!bp->SharedMemAddr) {
416 printk("could not allocate mem for "); 416 printk("could not allocate mem for ");
417 printk("hardware module: %ld byte\n", 417 printk("hardware module: %ld byte\n",
418 bp->SharedMemSize); 418 bp->SharedMemSize);
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 4adf12422787..a4f2bd52e546 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -148,7 +148,7 @@ static int full_duplex[MAX_UNITS] = {0, };
148 * This SUCKS. 148 * This SUCKS.
149 * We need a much better method to determine if dma_addr_t is 64-bit. 149 * We need a much better method to determine if dma_addr_t is 64-bit.
150 */ 150 */
151#if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__alpha__) || defined(__mips64__) || (defined(__mips__) && defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) || (defined(__powerpc64__) || defined(CONFIG_PHYS_64BIT)) 151#if (defined(__i386__) && defined(CONFIG_HIGHMEM64G)) || defined(__x86_64__) || defined (__ia64__) || defined(__alpha__) || (defined(CONFIG_MIPS) && ((defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) || defined(CONFIG_64BIT))) || (defined(__powerpc64__) || defined(CONFIG_PHYS_64BIT))
152/* 64-bit dma_addr_t */ 152/* 64-bit dma_addr_t */
153#define ADDR_64BITS /* This chip uses 64 bit addresses. */ 153#define ADDR_64BITS /* This chip uses 64 bit addresses. */
154#define netdrv_addr_t __le64 154#define netdrv_addr_t __le64
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 30ccbb6d097a..6f97b7bbcbf1 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -12658,7 +12658,7 @@ static void __devinit tg3_read_vpd(struct tg3 *tp)
12658 cnt = pci_read_vpd(tp->pdev, pos, 12658 cnt = pci_read_vpd(tp->pdev, pos,
12659 TG3_NVM_VPD_LEN - pos, 12659 TG3_NVM_VPD_LEN - pos,
12660 &vpd_data[pos]); 12660 &vpd_data[pos]);
12661 if (cnt == -ETIMEDOUT || -EINTR) 12661 if (cnt == -ETIMEDOUT || cnt == -EINTR)
12662 cnt = 0; 12662 cnt = 0;
12663 else if (cnt < 0) 12663 else if (cnt < 0)
12664 goto out_not_found; 12664 goto out_not_found;
diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c
index 44447f54942f..99ac70e32556 100644
--- a/drivers/usb/atm/ueagle-atm.c
+++ b/drivers/usb/atm/ueagle-atm.c
@@ -2206,8 +2206,11 @@ static int uea_boot(struct uea_softc *sc)
2206 goto err1; 2206 goto err1;
2207 } 2207 }
2208 2208
2209 sc->kthread = kthread_run(uea_kthread, sc, "ueagle-atm"); 2209 /* Create worker thread, but don't start it here. Start it after
2210 if (sc->kthread == ERR_PTR(-ENOMEM)) { 2210 * all usbatm generic initialization is done.
2211 */
2212 sc->kthread = kthread_create(uea_kthread, sc, "ueagle-atm");
2213 if (IS_ERR(sc->kthread)) {
2211 uea_err(INS_TO_USBDEV(sc), "failed to create thread\n"); 2214 uea_err(INS_TO_USBDEV(sc), "failed to create thread\n");
2212 goto err2; 2215 goto err2;
2213 } 2216 }
@@ -2624,6 +2627,7 @@ static struct usbatm_driver uea_usbatm_driver = {
2624static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id) 2627static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
2625{ 2628{
2626 struct usb_device *usb = interface_to_usbdev(intf); 2629 struct usb_device *usb = interface_to_usbdev(intf);
2630 int ret;
2627 2631
2628 uea_enters(usb); 2632 uea_enters(usb);
2629 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n", 2633 uea_info(usb, "ADSL device founded vid (%#X) pid (%#X) Rev (%#X): %s\n",
@@ -2637,7 +2641,19 @@ static int uea_probe(struct usb_interface *intf, const struct usb_device_id *id)
2637 if (UEA_IS_PREFIRM(id)) 2641 if (UEA_IS_PREFIRM(id))
2638 return uea_load_firmware(usb, UEA_CHIP_VERSION(id)); 2642 return uea_load_firmware(usb, UEA_CHIP_VERSION(id));
2639 2643
2640 return usbatm_usb_probe(intf, id, &uea_usbatm_driver); 2644 ret = usbatm_usb_probe(intf, id, &uea_usbatm_driver);
2645 if (ret == 0) {
2646 struct usbatm_data *usbatm = usb_get_intfdata(intf);
2647 struct uea_softc *sc = usbatm->driver_data;
2648
2649 /* Ensure carrier is initialized to off as early as possible */
2650 UPDATE_ATM_SIGNAL(ATM_PHY_SIG_LOST);
2651
2652 /* Only start the worker thread when all init is done */
2653 wake_up_process(sc->kthread);
2654 }
2655
2656 return ret;
2641} 2657}
2642 2658
2643static void uea_disconnect(struct usb_interface *intf) 2659static void uea_disconnect(struct usb_interface *intf)
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index f19e347f56f6..543b3262d002 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1430,7 +1430,7 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
1430 struct net_bridge_port *port, 1430 struct net_bridge_port *port,
1431 struct sk_buff *skb) 1431 struct sk_buff *skb)
1432{ 1432{
1433 struct sk_buff *skb2 = skb; 1433 struct sk_buff *skb2;
1434 struct ipv6hdr *ip6h; 1434 struct ipv6hdr *ip6h;
1435 struct icmp6hdr *icmp6h; 1435 struct icmp6hdr *icmp6h;
1436 u8 nexthdr; 1436 u8 nexthdr;
@@ -1469,15 +1469,15 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
1469 if (!skb2) 1469 if (!skb2)
1470 return -ENOMEM; 1470 return -ENOMEM;
1471 1471
1472 err = -EINVAL;
1473 if (!pskb_may_pull(skb2, offset + sizeof(struct icmp6hdr)))
1474 goto out;
1475
1472 len -= offset - skb_network_offset(skb2); 1476 len -= offset - skb_network_offset(skb2);
1473 1477
1474 __skb_pull(skb2, offset); 1478 __skb_pull(skb2, offset);
1475 skb_reset_transport_header(skb2); 1479 skb_reset_transport_header(skb2);
1476 1480
1477 err = -EINVAL;
1478 if (!pskb_may_pull(skb2, sizeof(*icmp6h)))
1479 goto out;
1480
1481 icmp6h = icmp6_hdr(skb2); 1481 icmp6h = icmp6_hdr(skb2);
1482 1482
1483 switch (icmp6h->icmp6_type) { 1483 switch (icmp6h->icmp6_type) {
@@ -1516,7 +1516,12 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
1516 switch (icmp6h->icmp6_type) { 1516 switch (icmp6h->icmp6_type) {
1517 case ICMPV6_MGM_REPORT: 1517 case ICMPV6_MGM_REPORT:
1518 { 1518 {
1519 struct mld_msg *mld = (struct mld_msg *)icmp6h; 1519 struct mld_msg *mld;
1520 if (!pskb_may_pull(skb2, sizeof(*mld))) {
1521 err = -EINVAL;
1522 goto out;
1523 }
1524 mld = (struct mld_msg *)skb_transport_header(skb2);
1520 BR_INPUT_SKB_CB(skb2)->mrouters_only = 1; 1525 BR_INPUT_SKB_CB(skb2)->mrouters_only = 1;
1521 err = br_ip6_multicast_add_group(br, port, &mld->mld_mca); 1526 err = br_ip6_multicast_add_group(br, port, &mld->mld_mca);
1522 break; 1527 break;
@@ -1529,15 +1534,18 @@ static int br_multicast_ipv6_rcv(struct net_bridge *br,
1529 break; 1534 break;
1530 case ICMPV6_MGM_REDUCTION: 1535 case ICMPV6_MGM_REDUCTION:
1531 { 1536 {
1532 struct mld_msg *mld = (struct mld_msg *)icmp6h; 1537 struct mld_msg *mld;
1538 if (!pskb_may_pull(skb2, sizeof(*mld))) {
1539 err = -EINVAL;
1540 goto out;
1541 }
1542 mld = (struct mld_msg *)skb_transport_header(skb2);
1533 br_ip6_multicast_leave_group(br, port, &mld->mld_mca); 1543 br_ip6_multicast_leave_group(br, port, &mld->mld_mca);
1534 } 1544 }
1535 } 1545 }
1536 1546
1537out: 1547out:
1538 __skb_push(skb2, offset); 1548 kfree_skb(skb2);
1539 if (skb2 != skb)
1540 kfree_skb(skb2);
1541 return err; 1549 return err;
1542} 1550}
1543#endif 1551#endif
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 35cf27087b56..e3d7aefa9181 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -50,6 +50,8 @@ static void br_send_bpdu(struct net_bridge_port *p,
50 50
51 llc_mac_hdr_init(skb, p->dev->dev_addr, p->br->group_addr); 51 llc_mac_hdr_init(skb, p->dev->dev_addr, p->br->group_addr);
52 52
53 skb_reset_mac_header(skb);
54
53 NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev, 55 NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
54 dev_queue_xmit); 56 dev_queue_xmit);
55} 57}
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 6faa8256e10c..9d5e8accfab1 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -125,7 +125,7 @@ struct bcm_sock {
125 struct list_head tx_ops; 125 struct list_head tx_ops;
126 unsigned long dropped_usr_msgs; 126 unsigned long dropped_usr_msgs;
127 struct proc_dir_entry *bcm_proc_read; 127 struct proc_dir_entry *bcm_proc_read;
128 char procname [20]; /* pointer printed in ASCII with \0 */ 128 char procname [32]; /* inode number in decimal with \0 */
129}; 129};
130 130
131static inline struct bcm_sock *bcm_sk(const struct sock *sk) 131static inline struct bcm_sock *bcm_sk(const struct sock *sk)
@@ -1521,7 +1521,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
1521 1521
1522 if (proc_dir) { 1522 if (proc_dir) {
1523 /* unique socket address as filename */ 1523 /* unique socket address as filename */
1524 sprintf(bo->procname, "%p", sock); 1524 sprintf(bo->procname, "%lu", sock_i_ino(sk));
1525 bo->bcm_proc_read = proc_create_data(bo->procname, 0644, 1525 bo->bcm_proc_read = proc_create_data(bo->procname, 0644,
1526 proc_dir, 1526 proc_dir,
1527 &bcm_proc_fops, sk); 1527 &bcm_proc_fops, sk);
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index df948b0f1ac9..93bfd95584f4 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2649,8 +2649,12 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp,
2649 } 2649 }
2650 2650
2651 if (res.type == RTN_LOCAL) { 2651 if (res.type == RTN_LOCAL) {
2652 if (!fl.fl4_src) 2652 if (!fl.fl4_src) {
2653 fl.fl4_src = fl.fl4_dst; 2653 if (res.fi->fib_prefsrc)
2654 fl.fl4_src = res.fi->fib_prefsrc;
2655 else
2656 fl.fl4_src = fl.fl4_dst;
2657 }
2654 dev_out = net->loopback_dev; 2658 dev_out = net->loopback_dev;
2655 fl.oif = dev_out->ifindex; 2659 fl.oif = dev_out->ifindex;
2656 res.fi = NULL; 2660 res.fi = NULL;