~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to fs/squashfs/xz_wrapper.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <linux/buffer_head.h>
27
27
#include <linux/slab.h>
28
28
#include <linux/xz.h>
 
29
#include <linux/bitops.h>
29
30
 
30
31
#include "squashfs_fs.h"
31
32
#include "squashfs_fs_sb.h"
32
 
#include "squashfs_fs_i.h"
33
33
#include "squashfs.h"
34
34
#include "decompressor.h"
35
35
 
38
38
        struct xz_buf buf;
39
39
};
40
40
 
41
 
static void *squashfs_xz_init(struct squashfs_sb_info *msblk)
 
41
struct comp_opts {
 
42
        __le32 dictionary_size;
 
43
        __le32 flags;
 
44
};
 
45
 
 
46
static void *squashfs_xz_init(struct squashfs_sb_info *msblk, void *buff,
 
47
        int len)
42
48
{
43
 
        int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
44
 
 
45
 
        struct squashfs_xz *stream = kmalloc(sizeof(*stream), GFP_KERNEL);
46
 
        if (stream == NULL)
47
 
                goto failed;
48
 
 
49
 
        stream->state = xz_dec_init(XZ_PREALLOC, block_size);
50
 
        if (stream->state == NULL)
51
 
                goto failed;
 
49
        struct comp_opts *comp_opts = buff;
 
50
        struct squashfs_xz *stream;
 
51
        int dict_size = msblk->block_size;
 
52
        int err, n;
 
53
 
 
54
        if (comp_opts) {
 
55
                /* check compressor options are the expected length */
 
56
                if (len < sizeof(*comp_opts)) {
 
57
                        err = -EIO;
 
58
                        goto failed;
 
59
                }
 
60
 
 
61
                dict_size = le32_to_cpu(comp_opts->dictionary_size);
 
62
 
 
63
                /* the dictionary size should be 2^n or 2^n+2^(n+1) */
 
64
                n = ffs(dict_size) - 1;
 
65
                if (dict_size != (1 << n) && dict_size != (1 << n) +
 
66
                                                (1 << (n + 1))) {
 
67
                        err = -EIO;
 
68
                        goto failed;
 
69
                }
 
70
        }
 
71
 
 
72
        dict_size = max_t(int, dict_size, SQUASHFS_METADATA_SIZE);
 
73
 
 
74
        stream = kmalloc(sizeof(*stream), GFP_KERNEL);
 
75
        if (stream == NULL) {
 
76
                err = -ENOMEM;
 
77
                goto failed;
 
78
        }
 
79
 
 
80
        stream->state = xz_dec_init(XZ_PREALLOC, dict_size);
 
81
        if (stream->state == NULL) {
 
82
                kfree(stream);
 
83
                err = -ENOMEM;
 
84
                goto failed;
 
85
        }
52
86
 
53
87
        return stream;
54
88
 
55
89
failed:
56
 
        ERROR("Failed to allocate xz workspace\n");
57
 
        kfree(stream);
58
 
        return NULL;
 
90
        ERROR("Failed to initialise xz decompressor\n");
 
91
        return ERR_PTR(err);
59
92
}
60
93
 
61
94