crypto: msm: check potential integer overflow on AEAD req length

According to the specification of AEAD, AEAD request cryptlen is
not a Fixed maximum and assoclen is also same. This could lead to
potential integer overflow, thus allocating less memory. So we
need to check potential integer overflow on AEAD request length.

Change-Id: I58a0c5e1a6e890bad30f7865e96b7db46337158c
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: multiple qce50 support

In some platforms such as fsm9900, multiple instances of qce50 hw
may be supported.  Each qce50 HW has an ndp-bam. Each qce50 HW
can support multiple instances of qce_dev platform device.
Each qce_dev has its own configured pipe set and associated qce50 HW,
defined by crypto-base and bam-pipe-pair fields in the device tree files.
This patch based on io address, it decides to create a new qce50 hw
instance or use the existing known instance at device probe time.

Furthermore, this patch does iomap for only once for each HW BAM instance
to avoid issue with bam driver. If modprobe, and rmmod of qcedev,
and qcrypto are not in first in last out order, kernel may crash in
bam driver in the last rmmod.
This saves virtual space for IO if multiple instances of qcedev
share the same instance of HW BAM.

Change-Id: I1565b1976981b0512832ff793e0adb29c4be3ccc
Acked-by: Chemin Hsieh <cheminh@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: Fix memory leak in bam_release call

Release pmab memory when an error occurs as well.

Change-Id: I7aa13d5a03edbdfa806345039459feaeac6e7a11
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: Fix issues related to non-zero byteoffset input

Fix buffer overflow for a non-zero byteoffset value.

Also fixes memory leak issue by adding data_len check in check_params.
One of the scenarios data_len can be less than byteoffset which results
in memory leak with huge data length, which might cause the kernel panic.

Change-Id: I3f773673219f45dad4f17499b1ee0feda2aff1f7
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
crypto: msm: Remove invalid check in qcedev driver

Unsigned int variable is compared for < 0, which is an invalid if
condition. This patch removes the check.

Change-Id: I76c10223672db2c387e025697dd8bd921e5ddc1b
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
crypto: msm: Use scnprintf() instead of snprintf()

snprintf can return more than the size of buffer, which is not
expected here, obviously. Use scnprintf instead.

Change-Id: I3b97a016df910728dfef5a0914ab8ad67c68e39c
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
crypto: msm: Fix null pointer exception in qcrypto_count_sg()

Fixes null pointer exception in count scatter gather function. Scatter
gather list pointer become NULL if the sg pointer reaches last but one
node, which results in NULL pointer exception.

Change-Id: I634baf30074e6e53ffa22635565da54e9ae43150
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>
Revert "crypto: Fix memory leak in bam_release call"

This reverts commit I7aa13d5a03edbdfa806345039459feaeac6e7a11, which
release pbam memory when an error occurs. However, on a device with
multiple ce, pbam memory is shared by multiple pce_dev, it can only
be freed when the reference count goes to zero, and can not be
released it if reference count is not zero when an error occurs.
The previous implementation on bam_release was correct, so we
revert commit I7aa13d5a03edbdfa806345039459feaeac6e7a11.

Change-Id: Id8bab91f57fe8056e441afdeae45d7dabbd1eae8
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
rhine: enable qcom crypto

Change-Id: If65bea9230fefe4ea74fc511186d12b5dac90482
netfilter: x_tables: fix ordering of jumpstack allocation and table update

During kernel stability testing on an SMP ARMv7 system, Yalin Wang
reported the following panic from the netfilter code:

  1fe0: 0000001c 5e2d3b10 4007e779 4009e110 60000010 00000032 ff565656 ff545454
  [<c06c48dc>] (ipt_do_table+0x448/0x584) from [<c0655ef0>] (nf_iterate+0x48/0x7c)
  [<c0655ef0>] (nf_iterate+0x48/0x7c) from [<c0655f7c>] (nf_hook_slow+0x58/0x104)
  [<c0655f7c>] (nf_hook_slow+0x58/0x104) from [<c0683bbc>] (ip_local_deliver+0x88/0xa8)
  [<c0683bbc>] (ip_local_deliver+0x88/0xa8) from [<c0683718>] (ip_rcv_finish+0x418/0x43c)
  [<c0683718>] (ip_rcv_finish+0x418/0x43c) from [<c062b1c4>] (__netif_receive_skb+0x4cc/0x598)
  [<c062b1c4>] (__netif_receive_skb+0x4cc/0x598) from [<c062b314>] (process_backlog+0x84/0x158)
  [<c062b314>] (process_backlog+0x84/0x158) from [<c062de84>] (net_rx_action+0x70/0x1dc)
  [<c062de84>] (net_rx_action+0x70/0x1dc) from [<c0088230>] (__do_softirq+0x11c/0x27c)
  [<c0088230>] (__do_softirq+0x11c/0x27c) from [<c008857c>] (do_softirq+0x44/0x50)
  [<c008857c>] (do_softirq+0x44/0x50) from [<c0088614>] (local_bh_enable_ip+0x8c/0xd0)
  [<c0088614>] (local_bh_enable_ip+0x8c/0xd0) from [<c06b0330>] (inet_stream_connect+0x164/0x298)
  [<c06b0330>] (inet_stream_connect+0x164/0x298) from [<c061d68c>] (sys_connect+0x88/0xc8)
  [<c061d68c>] (sys_connect+0x88/0xc8) from [<c000e340>] (ret_fast_syscall+0x0/0x30)
  Code: 2a000021 e59d2028 e59de01c e59f011c (e7824103)
  ---[ end trace da227214a82491bd ]---
  Kernel panic - not syncing: Fatal exception in interrupt

This comes about because CPU1 is executing xt_replace_table in response
to a setsockopt syscall, resulting in:

	ret = xt_jumpstack_alloc(newinfo);
		--> newinfo->jumpstack = kzalloc(size, GFP_KERNEL);

	[...]

	table->private = newinfo;
	newinfo->initial_entries = private->initial_entries;

Meanwhile, CPU0 is handling the network receive path and ends up in
ipt_do_table, resulting in:

	private = table->private;

	[...]

	jumpstack  = (struct ipt_entry **)private->jumpstack[cpu];

On weakly ordered memory architectures, the writes to table->private
and newinfo->jumpstack from CPU1 can be observed out of order by CPU0.
Furthermore, on architectures which don't respect ordering of address
dependencies (i.e. Alpha), the reads from CPU0 can also be re-ordered.

This patch adds an smp_wmb() before the assignment to table->private
(which is essentially publishing newinfo) to ensure that all writes to
newinfo will be observed before plugging it into the table structure.
A dependent-read barrier is also added on the consumer sides, to ensure
the same ordering requirements are also respected there.

Change-Id: Ia320d52510d7184c0f13d7f130102dbe685e8d6f
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Reported-by: Wang, Yalin <Yalin.Wang@sonymobile.com>
Tested-by: Wang, Yalin <Yalin.Wang@sonymobile.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Git-commit: b416c144f46af1a30ddfa4e4319a8f077381ad63
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Osvaldo Banuelos <osvaldob@codeaurora.org>
msm: wlan: update db.txt for Taiwan

After pulling in regulatory information for Taiwan
from the compliance team the data for Taiwan was
inconsistent as it allowed 80MHz bandwidth for
frequency range which was less than 80MHz which was
resulting in failure to parse the regulatory rules
for Taiwan.

Change-Id: Ibfabf26c1481b37d163b755734491ba27b1a4195
CRs-Fixed: 582871
Signed-off-by: Mihir Shete <smihir@codeaurora.org>
net/wireless: Fix kernel crash while doing iwlist scan

Remove the code that extracts the information of the rates without
the check for the corresponding bands. Also , this part of the code
is redundant as the following code checks for the same, which also
prevents a possible crash.

Change-Id: I1b4d243cd65f8890f4f7ab4cddf72aad261d7bb0
Signed-off-by: Ming-yi Lin <mylin@codeaurora.org>
wcnss: Add support to configure the Wlan MAC addr

This change introduces a sysfs entry to allow userspace to
configure the wlan MAC addr and exports an API which allows
WLAN and other wireless technologies to query the wlan MAC
addr

Change-Id: I751b2cf2db1321926e8e16ef1baaa4fa3d8d06cf
CRs-Fixed: 583465
Signed-off-by:  <hkpatel@codeaurora.org>
wlan: Store avoid channel list

Store avoid channel list into recoverable location.
If Softap mode detects current channel is not safe to use,
WLAN kernel module will be restarted.
Then WLAN kernel module internal storage will lost
unsafe channel information.
To avoid start softap with unsafe channel, channel information
should be stored in static location.

Change-Id: I5a6d7ab7314936d7bbaaf7a005e58179a4dc0613
CRs-fixed: 576020
Signed-off-by: Leo Chang <leochang@codeaurora.org>
zram: use 3.10 version of zram

commit 25eeb667599b192ea850a062d69383ee864c06ab
Author: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Date:   Wed Mar 13 15:06:16 2013 +0800

    zram: fix zram_bvec_read duplicate dump failure message and stat accumulation

    When zram decompress fails, the code unnecessarily dumps failure messages and
    does stat accumulation in function zram_decompress_page(), this work is already
    done in function zram_decompress_page, the patch skips the redundant work.

    Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 78110bb8dc4a7ff331bfa3cfe7d4e287cfb3f22b
Author: Joe Perches <joe@perches.com>
Date:   Mon Feb 11 09:41:29 2013 -0800

    staging: Remove unnecessary OOM messages

    alloc failures already get standardized OOM
    messages and a dump_stack.

    For the affected mallocs around these OOM messages:

    Converted kzallocs with multiplies to kcalloc.
    Converted kmallocs with multiplies to kmalloc_array.
    Converted a kmalloc/strlen/strncpy to kstrdup.
    Moved a spin_lock below a removed OOM message and
    removed a now unnecessary spin_unlock.
    Neatened alignment and whitespace.

    Signed-off-by: Joe Perches <joe@perches.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 1e927711c5ecabe76010ed9249f8f3747829f04f
Author: Fengguang Wu <fengguang.wu@intel.com>
Date:   Fri Feb 8 10:15:10 2013 +0800

    staging: zram: __zram_reset_device() can be static

    Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
    Cc: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8b3cc3edb745cbc131560d19e3f32d81c07454b1
Author: Minchan Kim <minchan@kernel.org>
Date:   Wed Feb 6 08:48:53 2013 +0900

    zram: get rid of lockdep warning

    Lockdep complains about recursive deadlock of zram->init_lock.
    [1] made it false positive because we can't request IO to zram
    before setting disksize. Anyway, we should shut lockdep up to
    avoid many reporting from user.

    [1] : zram: force disksize setting before using zram

    Acked-by: Jerome Marchand <jmarchan@redhat.com>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 152bce6bdd6e6866ff83166ac75177d001c4360d
Author: Minchan Kim <minchan@kernel.org>
Date:   Wed Feb 6 08:45:22 2013 +0900

    zram: fix warning of print format

    kbuild bot whinges due to print format mistmatch caused by
    zram: force disksize setting before using zram.

    This patch fixes it.

    Reported-by: Wu Fengguang <fengguang.wu@intel.com>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 3de738cd30306f754ea35d35b5dad29fdbec84c9
Author: Minchan Kim <minchan@kernel.org>
Date:   Wed Jan 30 11:41:41 2013 +0900

    zram: give up lazy initialization of zram metadata

    1) User of zram normally do mkfs.xxx or mkswap before using
       the zram block device(ex, normally, do it at booting time)
       It ends up allocating such metadata of zram before real usage so
       benefit of lazy initialzation would be mitigated.

    2) Some user want to use zram when memory pressure is high.(ie, load zram
       dynamically, NOT booting time). It does make sense because people don't
       want to waste memory until memory pressure is high(ie, where zram is really
       helpful time). In this case, lazy initialzation could be failed easily
       because we will use GFP_NOIO instead of GFP_KERNEL for avoiding deadlock.
       So the benefit of lazy initialzation would be mitigated, too.

    3) Metadata overhead is not critical and Nitin has a plan to diet it.
       4K : 12 byte(64bit machine) -> 64G : 192M so 0.3% isn't big overhead
       If insane user use such big zram device up to 20, it could consume 6% of ram
       but efficieny of zram will cover the waste.

    So this patch gives up lazy initialization and instead we initialize metadata
    at disksize setting time.

    Acked-by: Jerome Marchand <jmarchand@redhat.com>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0231c403bb065307493fe997ad170487b4d55eb8
Author: Minchan Kim <minchan@kernel.org>
Date:   Wed Jan 30 11:41:40 2013 +0900

    zram: force disksize setting before using zram

    Now zram document syas "set disksize is optional"
    but partly it's wrong. When you try to use zram firstly after
    booting, you must set disksize, otherwise zram can't work because
    zram gendisk's size is 0. But once you do it, you can use zram freely
    after reset because reset doesn't reset to zero paradoxically.
    So in this time, disksize setting is optional.:(
    It's inconsitent for user behavior and not straightforward.

    This patch forces always setting disksize firstly before using zram.
    Yes. It changes current behavior so someone could complain when
    he upgrades zram. Apparently it could be a problem if zram is mainline
    but it still lives in staging so behavior could be changed for right
    way to go. Let them excuse.

    Acked-by: Jerome Marchand <jmarchand@redhat.com>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Acked-by: Dan Magenheimer <dan.magenheimer@oracle.com>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 7e5a5104c6af709a8d97d5f4711e7c917761d464
Author: Minchan Kim <minchan@kernel.org>
Date:   Wed Jan 30 11:41:39 2013 +0900

    zram: Fix deadlock bug in partial read/write

    Now zram allocates new page with GFP_KERNEL in zram I/O path
    if IO is partial. Unfortunately, It may cause deadlock with
    reclaim path like below.

    write_page from fs
    fs_lock
    allocation(GFP_KERNEL)
    reclaim
    pageout
    				write_page from fs
    				fs_lock <-- deadlock

    This patch fixes it by using GFP_NOIO.  In read path, we
    reorganize code flow so that kmap_atomic is called after the
    GFP_NOIO allocation.

    Cc: stable@vger.kernel.org
    Acked-by: Jerome Marchand <jmarchand@redhat.com>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    [ penberg@kernel.org: don't use GFP_ATOMIC ]
    Signed-off-by: Pekka Enberg <penberg@kernel.org>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 0d145a501778042d0411c843ed5b468b41f8a171
Author: Seth Jennings <sjenning@linux.vnet.ibm.com>
Date:   Wed Jan 30 09:36:52 2013 -0600

    staging: zsmalloc: remove unused pool name

    zs_create_pool() currently takes a name argument which is
    never used in any useful way.

    This patch removes it.

    Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Acked-by: Rik van Riel <riel@redhat.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 8f5f90a872c38b4e78f3cc95e8a25434b98e4db2
Merge: c0cd2da 949db15
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Fri Jan 25 21:25:02 2013 -0800

    Merge 3.8-rc5 into staging-next

    This resolves a merge issue with a iio driver, and the zram code.

    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit d178a07c4bd380492b6aca9e5d3985c19ca88fdb
Author: Davidlohr Bueso <davidlohr.bueso@hp.com>
Date:   Tue Jan 1 21:24:29 2013 -0800

    staging: zram: drop zram_stat_dec/inc functions

    It seems like an overkill to have adding and subtracting
    1 functions from the 32bit counters. Just do it directly.

    Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cad683fb9d53fa2cbcf82660e663fa1180f86797
Author: Davidlohr Bueso <davidlohr.bueso@hp.com>
Date:   Tue Jan 1 21:24:22 2013 -0800

    staging: zram: show correct disksize

    The ->disksize variable stores values in units of bytes,
    print the correct size in Kb

    Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit ca3d70bd68455133eabcb8a0ae1b40254d87188b
Author: Davidlohr Bueso <davidlohr.bueso@hp.com>
Date:   Tue Jan 1 21:24:13 2013 -0800

    staging: zram: simplify num_devices paramater

    Simplify dealing with num_devices when initializing zram.
    Also cleanup some of the output messages.

    Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 397c60668aa5ae7130b5ad4e73870d7b8a787085
Author: Nitin Gupta <ngupta@vflare.org>
Date:   Wed Jan 2 08:53:41 2013 -0800

    staging: zram: fix invalid memory references during disk write

    Fixes a bug introduced by commit c8f2f0db1 ("zram: Fix handling
    of incompressible pages") which caused invalid memory references
    during disk write. Invalid references could occur in two cases:
     - Incoming data expands on compression: In this case, reference was
    made to kunmap()'ed bio page.
     - Partial (non PAGE_SIZE) write with incompressible data: In this
    case, reference was made to a kfree()'ed buffer.

    Fixes bug 50081:
    https://bugzilla.kernel.org/show_bug.cgi?id=50081

    Signed-off-by: Nitin Gupta <ngupta@vflare.org>
    Cc: stable <stable@vger.kernel.org>
    Reported-by: Mihail Kasadjikov <hamer.mk@gmail.com>
    Reported-by: Tomas M <tomas@slax.org>
    Reviewed-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit dbc320f7490933eb6a073d82aceac75d5e7ce82b
Author: Masanari Iida <standby24x7@gmail.com>
Date:   Mon Jan 7 23:28:10 2013 +0900

    staging: Add angle bracket before and after the URL

    Add missing angle bracket before and after the URL.

    Signed-off-by: Masanari Iida <standby24x7@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 26907840e63b3187266db1865e76ea9e98b01b19
Author: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Date:   Tue Oct 30 22:42:31 2012 +0300

    staging: zram: handle mem suffixes in disk size zram_sysfs parameter

    Use memparse() to allow mem suffixes in disksize sysfs number.
    Examples:
        echo 256K > /sys/block/zram0/disksize
        echo 512M > /sys/block/zram0/disksize
        echo 1G > /sys/block/zram0/disksize

    Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Reviewed-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 37b51fdddf64e7ba0971d070428655f8d6f36578
Author: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Date:   Tue Oct 30 22:40:23 2012 +0300

    staging: zram: factor-out zram_decompress_page() function

    zram_bvec_read() shared decompress functionality with zram_read_before_write() function.
    Factor-out and make commonly used zram_decompress_page() function, which also simplified
    error handling in zram_bvec_read().

    Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
    Reviewed-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit cb1f6268acd7f1bca7153fa9ca187ffb73f60ab8
Merge: d9ff393 8f0d816
Author: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date:   Mon Oct 29 08:37:12 2012 -0700

    Merge 3.7-rc3 into staging-next

    This resolves the conflict with:
    	drivers/staging/comedi/drivers/amplc_dio200.c
    and syncs up the changes that happened in the staging directory for
    3.7-rc3.

    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c8f2f0db1d0294aaf37e8a85bea9bbc4aaf5c0fe
Author: Nitin Gupta <ngupta@vflare.org>
Date:   Wed Oct 10 17:42:18 2012 -0700

    staging: zram: Fix handling of incompressible pages

    Change 130f315a (staging: zram: remove special handle of uncompressed page)
    introduced a bug in the handling of incompressible pages which resulted in
    memory allocation failure for such pages.

    When a page expands on compression, say from 4K to 4K+30, we were trying to
    do zsmalloc(pool, 4K+30). However, the maximum size which zsmalloc can
    allocate is PAGE_SIZE (for obvious reasons), so such allocation requests
    always return failure (0).

    For a page that has compressed size larger than the original size (this may
    happen with already compressed or random data), there is no point storing
    the compressed version as that would take more space and would also require
    time for decompression when needed again. So, the fix is to store any page,
    whose compressed size exceeds a threshold (max_zpage_size), as-it-is i.e.
    without compression.  Memory required for storing this uncompressed page can
    then be requested from zsmalloc which supports PAGE_SIZE sized allocations.

    Lastly, the fix checks that we do not attempt to "decompress" the page which
    we stored in the uncompressed form -- we just memcpy() out such pages.

    Signed-off-by: Nitin Gupta <ngupta@vflare.org>
    Reported-by: viechweg@gmail.com
    Reported-by: paerley@gmail.com
    Reported-by: wu.tommy@gmail.com
    Acked-by: Minchan Kim <minchan@kernel.org>
    Cc: stable <stable@vger.kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 55dcbbb1bf7eef83bcd3e0ba8de0b359a45804ed
Author: Minchan Kim <minchan@kernel.org>
Date:   Wed Oct 10 08:49:52 2012 +0900

    staging: zram: correct obsolete comment on max_zpage_size

    Zram doesn't use xv_malloc any more so it doesn't have
    limitation about zobj_header.

    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit b74185108668ef966e663878adbad65e03bfcb43
Author: Seth Jennings <sjenning@linux.vnet.ibm.com>
Date:   Mon Jul 2 16:15:52 2012 -0500

    staging: zsmalloc: add mapping modes

    This patch improves mapping performance in zsmalloc by getting
    usage information from the user in the form of a "mapping mode"
    and using it to avoid unnecessary copying for objects that span
    pages.

    Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 6e2361720b9da9ec830d407da058ca1827e62b12
Author: Seth Jennings <sjenning@linux.vnet.ibm.com>
Date:   Mon Jun 25 11:14:36 2012 -0500

    staging: zram/zcache: swtich Kconfig dependency from X86 to ZSMALLOC

    This patch switches zcache and zram dependency to ZSMALLOC
    rather than X86.  There is no net change since ZSMALLOC
    depends on X86, however, this prevent further changes to
    these files as zsmalloc dependencies change.

    Signed-off-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 80677c2538283678c7b2ef7ebbd653a3fa54d086
Author: Sam Hansen <solid.se7en@gmail.com>
Date:   Thu Jun 7 16:03:48 2012 -0700

    staging: zram: conventions, __aligned() attribute

    Using the __aligned() attribute in favor of __attribute__((aligned(size)))

    Signed-off-by: Sam Hansen <solid.se7en@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 94b8435ff4d46dde75173da45564b0d65889dc64
Author: Sam Hansen <solid.se7en@gmail.com>
Date:   Thu Jun 7 16:03:47 2012 -0700

    staging: zram: conventions pr_warning -> pr_warn()

    Porting zram to use the pr_warn() function instead of the deprecated
    pr_warning().

    Signed-off-by: Sam Hansen <solid.se7en@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 130f315a174d127cbb90d4d1a4a7088dbcf930b5
Author: Minchan Kim <minchan@kernel.org>
Date:   Fri Jun 8 15:39:27 2012 +0900

    staging: zram: remove special handle of uncompressed page

    xvmalloc can't handle PAGE_SIZE page so that zram have to
    handle it specially but zsmalloc can do it so let's remove
    unnecessary special handling code.

    Quote from Nitin
    "I think page vs handle distinction was added since xvmalloc could not
    handle full page allocation. Now that zsmalloc allows full page
    allocation, we can just use it for both cases. This would also allow
    removing the ZRAM_UNCOMPRESSED flag. The only downside will be slightly
    slower code path for full page allocation but this event is anyways
    supposed to be rare, so should be fine."

    1. This patch reduces code very much.

     drivers/staging/zram/zram_drv.c   |  104 +++++--------------------------------
     drivers/staging/zram/zram_drv.h   |   17 +-----
     drivers/staging/zram/zram_sysfs.c |    6 +--
     3 files changed, 15 insertions(+), 112 deletions(-)

    2. change pages_expand with bad_compress so it can count
       bad compression(above 75%) ratio.

    3. remove zobj_header which is for back-reference for defragmentation
       because firstly, it's not used at the moment and zsmalloc can't handle
       bigger size than PAGE_SIZE so zram can't do it any more without redesign.

    Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit 374a69191d12a0525b7ffe1197abc30c4795a230
Author: Minchan Kim <minchan@kernel.org>
Date:   Fri Jun 8 15:39:26 2012 +0900

    staging: zram: fix random data read

    fd1a30de makes a bug that it uses (struct page *) as zsmalloc's handle
    although it's a uncompressed page so that it can access random page,
    return random data or even crashed by get_first_page in zs_map_object.

    Cc: Seth Jennings <sjenning@linux.vnet.ibm.com>
    Cc: Jerome Marchand <jmarchan@redhat.com>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

commit c234434835b1f4bad9bdbae6710044cba387c9e5
Author: Minchan Kim <minchan@kernel.org>
Date:   Fri Jun 8 15:39:25 2012 +0900

    staging: zsmalloc: zsmalloc: use unsigned long instead of void *

    We should use unsigned long as handle instead of void * to avoid any
    confusion. Without this, users may just treat zs_malloc return value as
    a pointer and try to deference it.

    This patch passed compile test(zram, zcache and ramster) and zram is
    tested on qemu.

    changelog
      * from v2
    	- remove hval pointed out by Nitin
    	- based on next-20120607
      * from v1
    	- change zcache's zv_create return value
    	- baesd on next-20120604

    Cc: Dan Magenheimer <dan.magenheimer@oracle.com>
    Acked-by: Seth Jennings <sjenning@linux.vnet.ibm.com>
    Acked-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
    Signed-off-by: Minchan Kim <minchan@kernel.org>
    Acked-by: Nitin Gupta <ngupta@vflare.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Change-Id: I5157794e120bbae7ba1e5d0f122dae4fba4a079b
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
Staging: Fixes string split across lines in zram

Fixes the following checkpatch warning in zram_drv.c:
WARNING: quoted string split across lines

Change-Id: Ie74672146a958c2636052f20a6340f67f2641cde
Signed-off-by: Marlies Ruck <marlies.ruck@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 596b3dd4c8e172db7806372c9d0347a4e7d28bc5
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
zram: avoid invalid memory access in zram_exit()

Memory for zram->disk object may have already been freed after returning
from destroy_device(zram), then it's unsafe for zram_reset_device(zram)
to access zram->disk again.

We can't solve this bug by flipping the order of destroy_device(zram)
and zram_reset_device(zram), that will cause deadlock issues to the
zram sysfs handler.

So fix it by holding an extra reference to zram->disk before calling
destroy_device(zram).

Change-Id: I1022247325ab2ec31a094587e13d5c4c759e5a36
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 6030ea9b35971a4200062f010341ab832e878ac9
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
zram: use zram->lock to protect zram_free_page() in swap free notify path

zram_slot_free_notify() is free-running without any protection from
concurrent operations. So there are race conditions between
zram_bvec_read()/zram_bvec_write() and zram_slot_free_notify(),
and possible consequences include:
1) Trigger BUG_ON(!handle) on zram_bvec_write() side.
2) Access to freed pages on zram_bvec_read() side.
3) Break some fields (bad_compress, good_compress, pages_stored)
   in zram->stats if the swap layer makes concurrently call to
   zram_slot_free_notify().

So enhance zram_slot_free_notify() to acquire writer lock on zram->lock
before calling zram_free_page().

Change-Id: I805806668d91aaf4c8be7359cb1fd9c877c41f72
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 57ab048532c0d975538cebd4456491b5c34248f4
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
zram: destroy all devices on error recovery path in zram_init()

On error recovery path of zram_init(), it leaks the zram device object
causing the failure. So change create_device() to free allocated
resources on error path.

Change-Id: Ia8508ab9aad3201c6fc12634b8e134d78d7d1423
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 39a9b8ac9333e4268ecff7da6c9d1ab3823ff243
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
zram: avoid double free in function zram_bvec_write()

When doing a patial write and the whole page is filled with zero,
zram_bvec_write() will free uncmem twice.

Change-Id: I233f44846f29dbf11e05d277506137bc7f11bbd9
Signed-off-by: Jiang Liu <jiang.liu@huawei.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Git-commit: 65c484609a3b25c35e4edcd5f2c38f98f5226093
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>