Skip to content
  1. Aug 28, 2010
    • Julia Lawall's avatar
      net/ipv4: Eliminate kstrdup memory leak · c34186ed
      Julia Lawall authored
      The string clone is only used as a temporary copy of the argument val
      within the while loop, and so it should be freed before leaving the
      function.  The call to strsep, however, modifies clone, so a pointer to the
      front of the string is kept in saved_clone, to make it possible to free it.
      
      The sematic match that finds this problem is as follows:
      (http://coccinelle.lip6.fr/
      
      )
      
      // <smpl>
      @r exists@
      local idexpression x;
      expression E;
      identifier l;
      statement S;
      @@
      
      *x= \(kasprintf\|kstrdup\)(...);
      ...
      if (x == NULL) S
      ... when != kfree(x)
          when != E = x
      if (...) {
        <... when != kfree(x)
      * goto l;
        ...>
      * return ...;
      }
      // </smpl>
      
      Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c34186ed
  2. Aug 27, 2010
  3. Aug 26, 2010
    • KOSAKI Motohiro's avatar
      tcp: select(writefds) don't hang up when a peer close connection · d84ba638
      KOSAKI Motohiro authored
      This issue come from ruby language community. Below test program
      hang up when only run on Linux.
      
      	% uname -mrsv
      	Linux 2.6.26-2-486 #1 Sat Dec 26 08:37:39 UTC 2009 i686
      	% ruby -rsocket -ve '
      	BasicSocket.do_not_reverse_lookup = true
      	serv = TCPServer.open("127.0.0.1", 0)
      	s1 = TCPSocket.open("127.0.0.1", serv.addr[1])
      	s2 = serv.accept
      	s2.close
      	s1.write("a") rescue p $!
      	s1.write("a") rescue p $!
      	Thread.new {
      	  s1.write("a")
      	}.join'
      	ruby 1.9.3dev (2010-07-06 trunk 28554) [i686-linux]
      	#<Errno::EPIPE: Broken pipe>
      	[Hang Here]
      
      FreeBSD, Solaris, Mac doesn't. because Ruby's write() method call
      select() internally. and tcp_poll has a bug.
      
      SUS defined 'ready for writing' of select() as following.
      
      |  A descriptor shall be considered ready for writing when a call to an output
      |  function with O_NONBLOCK clear would not block, whether or not the function
      |  would transfer data successfully.
      
      That said, EPIPE situation is clearly one of 'ready for writing'.
      
      We don't have read-side issue because tcp_poll() already has read side
      shutdown care.
      
      |        if (sk->sk_shutdown & RCV_SHUTDOWN)
      |                mask |= POLLIN | POLLRDNORM | POLLRDHUP;
      
      So, Let's insert same logic in write side.
      
      - reference url
        http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/31065
        http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/31068
      
      
      
      Signed-off-by: default avatarKOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d84ba638
    • Eric Dumazet's avatar
      tcp: fix three tcp sysctls tuning · c5ed63d6
      Eric Dumazet authored
      
      
      As discovered by Anton Blanchard, current code to autotune 
      tcp_death_row.sysctl_max_tw_buckets, sysctl_tcp_max_orphans and
      sysctl_max_syn_backlog makes little sense.
      
      The bigger a page is, the less tcp_max_orphans is : 4096 on a 512GB
      machine in Anton's case.
      
      (tcp_hashinfo.bhash_size * sizeof(struct inet_bind_hashbucket))
      is much bigger if spinlock debugging is on. Its wrong to select bigger
      limits in this case (where kernel structures are also bigger)
      
      bhash_size max is 65536, and we get this value even for small machines. 
      
      A better ground is to use size of ehash table, this also makes code
      shorter and more obvious.
      
      Based on a patch from Anton, and another from David.
      
      Reported-and-tested-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      c5ed63d6
  4. Aug 25, 2010
    • David S. Miller's avatar
      tcp: Combat per-cpu skew in orphan tests. · ad1af0fe
      David S. Miller authored
      
      
      As reported by Anton Blanchard when we use
      percpu_counter_read_positive() to make our orphan socket limit checks,
      the check can be off by up to num_cpus_online() * batch (which is 32
      by default) which on a 128 cpu machine can be as large as the default
      orphan limit itself.
      
      Fix this by doing the full expensive sum check if the optimized check
      triggers.
      
      Reported-by: default avatarAnton Blanchard <anton@samba.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Acked-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      ad1af0fe
    • Dan Carpenter's avatar
      pxa168_eth: silence gcc warnings · b2bc8563
      Dan Carpenter authored
      
      
      Casting "pep->tx_desc_dma" to to a struct tx_desc pointer makes gcc
      complain:
      
      drivers/net/pxa168_eth.c:657: warning:
      	cast to pointer from integer of different size
      
      Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      b2bc8563
    • Dan Carpenter's avatar
      pxa168_eth: update call to phy_mii_ioctl() · 4f2c8510
      Dan Carpenter authored
      
      
      The phy_mii_ioctl() function changed recently.  It now takes a struct
      ifreq pointer directly.
      
      Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4f2c8510
    • Dan Carpenter's avatar
      pxa168_eth: fix error handling in prope · 945c7c73
      Dan Carpenter authored
      
      
      A couple issues here:
      * Some resources weren't released.
      * If alloc_etherdev() failed it would have caused a NULL dereference
        because "pep" would be null when we checked "if (pep->clk)".
      * Also it's better to propagate the error codes from mdiobus_register()
        instead of just returning -ENOMEM.
      
      Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      945c7c73
    • Dan Carpenter's avatar
      pxa168_eth: remove unneeded null check · 4169591f
      Dan Carpenter authored
      
      
      "pep->pd" isn't checked consistently in this function.  For example it's
      dereferenced unconditionally on the next line after the end of the if
      condition.  This function is only called from pxa168_eth_probe() and
      pep->pd is always non-NULL so I removed the check.
      
      Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      4169591f
    • Anton Vorontsov's avatar
      phylib: Fix race between returning phydev and calling adjust_link · ef24b16b
      Anton Vorontsov authored
      
      
      It is possible that phylib will call adjust_link before returning
      from {,of_}phy_connect(), which may cause the following [very rare,
      though] oops upon reopening the device:
      
        Unable to handle kernel paging request for data at address 0x0000024c
        Oops: Kernel access of bad area, sig: 11 [#1]
        PREEMPT SMP NR_CPUS=2 LTT NESTING LEVEL : 0
        P1021 RDB
        Modules linked in:
        NIP: c0345dac LR: c0345dac CTR: c0345d84
        TASK = dffab6b0[30] 'events/0' THREAD: c0d24000 CPU: 0
        [...]
        NIP [c0345dac] adjust_link+0x28/0x19c
        LR [c0345dac] adjust_link+0x28/0x19c
        Call Trace:
        [c0d25f00] [000045e1] 0x45e1 (unreliable)
        [c0d25f30] [c036c158] phy_state_machine+0x3ac/0x554
        [...]
      
      Here is why. Drivers store phydev in their private structures, e.g.
      gianfar driver:
      
      static int init_phy(struct net_device *dev)
      {
      	...
      	priv->phydev = of_phy_connect(...);
      	...
      }
      
      So that adjust_link could retrieve it back:
      
      static void adjust_link(struct net_device *dev)
      {
      	...
      	struct phy_device *phydev = priv->phydev;
      	...
      }
      
      If the device has been opened before, then phydev->state is set to
      PHY_HALTED (or undefined if the driver didn't call phy_stop()).
      
      Now, phy_connect starts the PHY state machine before returning phydev to
      the driver:
      
      	phy_start_machine(phydev, NULL);
      
      	if (phydev->irq > 0)
      		phy_start_interrupts(phydev);
      
      	return phydev;
      
      The time between 'phy_start_machine()' and 'return phydev' is undefined.
      The start machine routine delays execution for 1 second, which is enough
      for most cases. But under heavy load, or if you're unlucky, it is quite
      possible that PHY state machine will execute before phy_connect()
      returns, and so adjust_link callback will try to dereference phydev,
      which is not yet ready.
      
      To fix the issue, simply initialize the PHY's state to PHY_READY during
      phy_attach(). This will ensure that phylib won't call adjust_link before
      phy_start().
      
      Signed-off-by: default avatarAnton Vorontsov <avorontsov@mvista.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      ef24b16b
    • Heiko Carstens's avatar
      caif-driver: add HAS_DMA dependency · 9dc002d8
      Heiko Carstens authored
      
      
      Fix this error on an s390 allyesconfig build:
      
      linux-2.6/drivers/net/caif/caif_spi.c:98:
          undefined reference to `dma_free_coherent'
      
      Cc: Sjur Braendeland <sjur.brandeland@stericsson.com>
      Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9dc002d8
  5. Aug 24, 2010
  6. Aug 23, 2010
    • Randy Dunlap's avatar
      isdn/avm: fix build when PCMCIA is not enabled · 6a6d01d3
      Randy Dunlap authored
      
      
      Why wouldn't kconfig symbol ISDN_DRV_AVMB1_B1PCMCIA also depend on
      PCMCIA?
      
      Fix build for PCMCIA not enabled:
      
      ERROR: "b1_free_card" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1ctl_proc_fops" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_reset_ctr" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_load_firmware" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_send_message" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_release_appl" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_register_appl" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_getrevision" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_detect" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_interrupt" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      ERROR: "b1_alloc_card" [drivers/isdn/hardware/avm/b1pcmcia.ko] undefined!
      
      Signed-off-by: default avatarRandy Dunlap <randy.dunlap@oracle.com>
      Cc: Carsten Paeth <calle@calle.de>
      Cc: Karsten Keil <isdn@linux-pingi.de>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      6a6d01d3
    • Changli Gao's avatar
      header: fix broken headers for user space · 09cd2b99
      Changli Gao authored
      
      
      __packed is only defined in kernel space, so we should use
      __attribute__((packed)) for the code shared between kernel and user space.
      
      Two __attribute() annotations are replaced with __attribute__() too.
      
      Signed-off-by: default avatarChangli Gao <xiaosuo@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      09cd2b99
  7. Aug 20, 2010
  8. Aug 19, 2010