diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-01 14:43:45 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-01 14:43:45 -0500 |
commit | a659f1598585071eed5c39485840b0f018c9f457 (patch) | |
tree | 9d785768a926c3dc2b42944b5851620684e00dba | |
parent | 06c8f7a7501ab3ae338a98ff8515b9f03160bea6 (diff) | |
parent | 1640eea35e8dcf0cb437f03c56868a97d0666df3 (diff) |
Merge tag 'kbuild-misc-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild misc updates from Masahiro Yamada:
- add snap-pkg target to create Linux kernel snap package
- make out-of-tree creation of source packages fail correctly
- improve and fix several semantic patches
* tag 'kbuild-misc-v4.16' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
Coccinelle: coccicheck: fix typo
Coccinelle: memdup: drop spurious line
Coccinelle: kzalloc-simple: Rename kzalloc-simple to zalloc-simple
Coccinelle: ifnullfree: Trim the warning reported in report mode
Coccinelle: alloc_cast: Add more memory allocating functions to the list
Coccinelle: array_size: report even if include is missing
Coccinelle: kzalloc-simple: Add all zero allocating functions
kbuild: pkg: make out-of-tree rpm/deb-pkg build immediately fail
scripts/package: snap-pkg target
-rw-r--r-- | .gitignore | 5 | ||||
-rwxr-xr-x | scripts/coccicheck | 2 | ||||
-rw-r--r-- | scripts/coccinelle/api/alloc/alloc_cast.cocci | 92 | ||||
-rw-r--r-- | scripts/coccinelle/api/alloc/kzalloc-simple.cocci | 86 | ||||
-rw-r--r-- | scripts/coccinelle/api/alloc/zalloc-simple.cocci | 448 | ||||
-rw-r--r-- | scripts/coccinelle/api/memdup.cocci | 1 | ||||
-rw-r--r-- | scripts/coccinelle/free/ifnullfree.cocci | 2 | ||||
-rw-r--r-- | scripts/coccinelle/misc/array_size.cocci | 4 | ||||
-rw-r--r-- | scripts/package/Makefile | 26 | ||||
-rw-r--r-- | scripts/package/snapcraft.template | 14 |
10 files changed, 565 insertions, 115 deletions
diff --git a/.gitignore b/.gitignore index f6050b88e95b..705e09913dc2 100644 --- a/.gitignore +++ b/.gitignore | |||
@@ -66,6 +66,11 @@ modules.builtin | |||
66 | /debian/ | 66 | /debian/ |
67 | 67 | ||
68 | # | 68 | # |
69 | # Snap directory (make snap-pkg) | ||
70 | # | ||
71 | /snap/ | ||
72 | |||
73 | # | ||
69 | # tar directory (make tar*-pkg) | 74 | # tar directory (make tar*-pkg) |
70 | # | 75 | # |
71 | /tar-install/ | 76 | /tar-install/ |
diff --git a/scripts/coccicheck b/scripts/coccicheck index ecfac64b39fe..9fedca611b7f 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck | |||
@@ -177,7 +177,7 @@ coccinelle () { | |||
177 | REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh) | 177 | REQ_NUM=$(echo $REQ | ${DIR}/scripts/ld-version.sh) |
178 | if [ "$REQ_NUM" != "0" ] ; then | 178 | if [ "$REQ_NUM" != "0" ] ; then |
179 | if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then | 179 | if [ "$SPATCH_VERSION_NUM" -lt "$REQ_NUM" ] ; then |
180 | echo "Skipping coccinele SmPL patch: $COCCI" | 180 | echo "Skipping coccinelle SmPL patch: $COCCI" |
181 | echo "You have coccinelle: $SPATCH_VERSION" | 181 | echo "You have coccinelle: $SPATCH_VERSION" |
182 | echo "This SmPL patch requires: $REQ" | 182 | echo "This SmPL patch requires: $REQ" |
183 | return | 183 | return |
diff --git a/scripts/coccinelle/api/alloc/alloc_cast.cocci b/scripts/coccinelle/api/alloc/alloc_cast.cocci index 6c308ee19b32..408ee3879f9b 100644 --- a/scripts/coccinelle/api/alloc/alloc_cast.cocci +++ b/scripts/coccinelle/api/alloc/alloc_cast.cocci | |||
@@ -5,10 +5,11 @@ | |||
5 | //# kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc, | 5 | //# kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc, |
6 | //# kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes | 6 | //# kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes |
7 | //# the casting as it is not required. The result in the patch case may | 7 | //# the casting as it is not required. The result in the patch case may |
8 | //#need some reformatting. | 8 | //# need some reformatting. |
9 | // | 9 | // |
10 | // Confidence: High | 10 | // Confidence: High |
11 | // Copyright: 2014, Himangi Saraogi GPLv2. | 11 | // Copyright: (C) 2014 Himangi Saraogi GPLv2. |
12 | // Copyright: (C) 2017 Himanshu Jha GPLv2. | ||
12 | // Comments: | 13 | // Comments: |
13 | // Options: --no-includes --include-headers | 14 | // Options: --no-includes --include-headers |
14 | // | 15 | // |
@@ -18,55 +19,104 @@ virtual patch | |||
18 | virtual org | 19 | virtual org |
19 | virtual report | 20 | virtual report |
20 | 21 | ||
22 | @initialize:python@ | ||
23 | @@ | ||
24 | import re | ||
25 | pattern = '__' | ||
26 | m = re.compile(pattern) | ||
27 | |||
28 | @r1 depends on context || patch@ | ||
29 | type T; | ||
30 | @@ | ||
31 | |||
32 | (T *) | ||
33 | \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | ||
34 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| | ||
35 | dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| | ||
36 | kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| | ||
37 | pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| | ||
38 | kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) | ||
39 | |||
21 | //---------------------------------------------------------- | 40 | //---------------------------------------------------------- |
22 | // For context mode | 41 | // For context mode |
23 | //---------------------------------------------------------- | 42 | //---------------------------------------------------------- |
24 | 43 | ||
25 | @depends on context@ | 44 | @script:python depends on context@ |
26 | type T; | 45 | t << r1.T; |
46 | @@ | ||
47 | |||
48 | if m.search(t) != None: | ||
49 | cocci.include_match(False) | ||
50 | |||
51 | @depends on context && r1@ | ||
52 | type r1.T; | ||
27 | @@ | 53 | @@ |
28 | 54 | ||
29 | * (T *) | 55 | * (T *) |
30 | \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | 56 | \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| |
31 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...) | 57 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| |
58 | dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| | ||
59 | kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| | ||
60 | pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| | ||
61 | kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) | ||
32 | 62 | ||
33 | //---------------------------------------------------------- | 63 | //---------------------------------------------------------- |
34 | // For patch mode | 64 | // For patch mode |
35 | //---------------------------------------------------------- | 65 | //---------------------------------------------------------- |
36 | 66 | ||
37 | @depends on patch@ | 67 | @script:python depends on patch@ |
38 | type T; | 68 | t << r1.T; |
69 | @@ | ||
70 | |||
71 | if m.search(t) != None: | ||
72 | cocci.include_match(False) | ||
73 | |||
74 | @depends on patch && r1@ | ||
75 | type r1.T; | ||
39 | @@ | 76 | @@ |
40 | 77 | ||
41 | - (T *) | 78 | - (T *) |
42 | (\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | 79 | \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| |
43 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)) | 80 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| |
81 | dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| | ||
82 | kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| | ||
83 | pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| | ||
84 | kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) | ||
44 | 85 | ||
45 | //---------------------------------------------------------- | 86 | //---------------------------------------------------------- |
46 | // For org and report mode | 87 | // For org and report mode |
47 | //---------------------------------------------------------- | 88 | //---------------------------------------------------------- |
48 | 89 | ||
49 | @r depends on org || report@ | 90 | @r2 depends on org || report@ |
50 | type T; | 91 | type T; |
51 | position p; | 92 | position p; |
52 | @@ | 93 | @@ |
53 | 94 | ||
54 | (T@p *)\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | 95 | (T@p *) |
55 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...) | 96 | \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| |
97 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\|vmalloc\|vzalloc\| | ||
98 | dma_alloc_coherent\|dma_zalloc_coherent\|devm_kmalloc\|devm_kzalloc\| | ||
99 | kvmalloc\|kvzalloc\|kvmalloc_node\|kvzalloc_node\|pci_alloc_consistent\| | ||
100 | pci_zalloc_consistent\|kmem_alloc\|kmem_zalloc\|kmem_zone_alloc\| | ||
101 | kmem_zone_zalloc\|vmalloc_node\|vzalloc_node\)(...) | ||
56 | 102 | ||
57 | @script:python depends on org@ | 103 | @script:python depends on org@ |
58 | p << r.p; | 104 | p << r2.p; |
59 | t << r.T; | 105 | t << r2.T; |
60 | @@ | 106 | @@ |
61 | 107 | ||
62 | coccilib.org.print_safe_todo(p[0], t) | 108 | if m.search(t) != None: |
109 | cocci.include_match(False) | ||
110 | else: | ||
111 | coccilib.org.print_safe_todo(p[0], t) | ||
63 | 112 | ||
64 | @script:python depends on report@ | 113 | @script:python depends on report@ |
65 | p << r.p; | 114 | p << r2.p; |
66 | t << r.T; | 115 | t << r2.T; |
67 | @@ | 116 | @@ |
68 | 117 | ||
69 | msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t) | 118 | if m.search(t) != None: |
70 | coccilib.report.print_report(p[0], msg) | 119 | cocci.include_match(False) |
71 | 120 | else: | |
72 | 121 | msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t) | |
122 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/api/alloc/kzalloc-simple.cocci b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci deleted file mode 100644 index 52c55e4fa67d..000000000000 --- a/scripts/coccinelle/api/alloc/kzalloc-simple.cocci +++ /dev/null | |||
@@ -1,86 +0,0 @@ | |||
1 | /// | ||
2 | /// Use kzalloc rather than kmalloc followed by memset with 0 | ||
3 | /// | ||
4 | /// This considers some simple cases that are common and easy to validate | ||
5 | /// Note in particular that there are no ...s in the rule, so all of the | ||
6 | /// matched code has to be contiguous | ||
7 | /// | ||
8 | // Confidence: High | ||
9 | // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. | ||
10 | // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
11 | // URL: http://coccinelle.lip6.fr/rules/kzalloc.html | ||
12 | // Options: --no-includes --include-headers | ||
13 | // | ||
14 | // Keywords: kmalloc, kzalloc | ||
15 | // Version min: < 2.6.12 kmalloc | ||
16 | // Version min: 2.6.14 kzalloc | ||
17 | // | ||
18 | |||
19 | virtual context | ||
20 | virtual patch | ||
21 | virtual org | ||
22 | virtual report | ||
23 | |||
24 | //---------------------------------------------------------- | ||
25 | // For context mode | ||
26 | //---------------------------------------------------------- | ||
27 | |||
28 | @depends on context@ | ||
29 | type T, T2; | ||
30 | expression x; | ||
31 | expression E1,E2; | ||
32 | statement S; | ||
33 | @@ | ||
34 | |||
35 | * x = (T)kmalloc(E1,E2); | ||
36 | if ((x==NULL) || ...) S | ||
37 | * memset((T2)x,0,E1); | ||
38 | |||
39 | //---------------------------------------------------------- | ||
40 | // For patch mode | ||
41 | //---------------------------------------------------------- | ||
42 | |||
43 | @depends on patch@ | ||
44 | type T, T2; | ||
45 | expression x; | ||
46 | expression E1,E2; | ||
47 | statement S; | ||
48 | @@ | ||
49 | |||
50 | - x = (T)kmalloc(E1,E2); | ||
51 | + x = kzalloc(E1,E2); | ||
52 | if ((x==NULL) || ...) S | ||
53 | - memset((T2)x,0,E1); | ||
54 | |||
55 | //---------------------------------------------------------- | ||
56 | // For org mode | ||
57 | //---------------------------------------------------------- | ||
58 | |||
59 | @r depends on org || report@ | ||
60 | type T, T2; | ||
61 | expression x; | ||
62 | expression E1,E2; | ||
63 | statement S; | ||
64 | position p; | ||
65 | @@ | ||
66 | |||
67 | x = (T)kmalloc@p(E1,E2); | ||
68 | if ((x==NULL) || ...) S | ||
69 | memset((T2)x,0,E1); | ||
70 | |||
71 | @script:python depends on org@ | ||
72 | p << r.p; | ||
73 | x << r.x; | ||
74 | @@ | ||
75 | |||
76 | msg="%s" % (x) | ||
77 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
78 | coccilib.org.print_todo(p[0], msg_safe) | ||
79 | |||
80 | @script:python depends on report@ | ||
81 | p << r.p; | ||
82 | x << r.x; | ||
83 | @@ | ||
84 | |||
85 | msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x) | ||
86 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci new file mode 100644 index 000000000000..92b20913055f --- /dev/null +++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci | |||
@@ -0,0 +1,448 @@ | |||
1 | /// | ||
2 | /// Use zeroing allocator rather than allocator followed by memset with 0 | ||
3 | /// | ||
4 | /// This considers some simple cases that are common and easy to validate | ||
5 | /// Note in particular that there are no ...s in the rule, so all of the | ||
6 | /// matched code has to be contiguous | ||
7 | /// | ||
8 | // Confidence: High | ||
9 | // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. | ||
10 | // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
11 | // Copyright: (C) 2017 Himanshu Jha GPLv2. | ||
12 | // URL: http://coccinelle.lip6.fr/rules/kzalloc.html | ||
13 | // Options: --no-includes --include-headers | ||
14 | // | ||
15 | // Keywords: kmalloc, kzalloc | ||
16 | // Version min: < 2.6.12 kmalloc | ||
17 | // Version min: 2.6.14 kzalloc | ||
18 | // | ||
19 | |||
20 | virtual context | ||
21 | virtual patch | ||
22 | virtual org | ||
23 | virtual report | ||
24 | |||
25 | //---------------------------------------------------------- | ||
26 | // For context mode | ||
27 | //---------------------------------------------------------- | ||
28 | |||
29 | @depends on context@ | ||
30 | type T, T2; | ||
31 | expression x; | ||
32 | expression E1; | ||
33 | statement S; | ||
34 | @@ | ||
35 | |||
36 | * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\| | ||
37 | kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\| | ||
38 | devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\| | ||
39 | kvmalloc_node(E1,...)\); | ||
40 | if ((x==NULL) || ...) S | ||
41 | * memset((T2)x,0,E1); | ||
42 | |||
43 | //---------------------------------------------------------- | ||
44 | // For patch mode | ||
45 | //---------------------------------------------------------- | ||
46 | |||
47 | @depends on patch@ | ||
48 | type T, T2; | ||
49 | expression x; | ||
50 | expression E1,E2,E3,E4; | ||
51 | statement S; | ||
52 | @@ | ||
53 | |||
54 | ( | ||
55 | - x = kmalloc(E1,E2); | ||
56 | + x = kzalloc(E1,E2); | ||
57 | | | ||
58 | - x = (T *)kmalloc(E1,E2); | ||
59 | + x = kzalloc(E1,E2); | ||
60 | | | ||
61 | - x = (T)kmalloc(E1,E2); | ||
62 | + x = (T)kzalloc(E1,E2); | ||
63 | | | ||
64 | - x = vmalloc(E1); | ||
65 | + x = vzalloc(E1); | ||
66 | | | ||
67 | - x = (T *)vmalloc(E1); | ||
68 | + x = vzalloc(E1); | ||
69 | | | ||
70 | - x = (T)vmalloc(E1); | ||
71 | + x = (T)vzalloc(E1); | ||
72 | | | ||
73 | - x = dma_alloc_coherent(E2,E1,E3,E4); | ||
74 | + x = dma_zalloc_coherent(E2,E1,E3,E4); | ||
75 | | | ||
76 | - x = (T *)dma_alloc_coherent(E2,E1,E3,E4); | ||
77 | + x = dma_zalloc_coherent(E2,E1,E3,E4); | ||
78 | | | ||
79 | - x = (T)dma_alloc_coherent(E2,E1,E3,E4); | ||
80 | + x = (T)dma_zalloc_coherent(E2,E1,E3,E4); | ||
81 | | | ||
82 | - x = kmalloc_node(E1,E2,E3); | ||
83 | + x = kzalloc_node(E1,E2,E3); | ||
84 | | | ||
85 | - x = (T *)kmalloc_node(E1,E2,E3); | ||
86 | + x = kzalloc_node(E1,E2,E3); | ||
87 | | | ||
88 | - x = (T)kmalloc_node(E1,E2,E3); | ||
89 | + x = (T)kzalloc_node(E1,E2,E3); | ||
90 | | | ||
91 | - x = kmem_cache_alloc(E3,E4); | ||
92 | + x = kmem_cache_zalloc(E3,E4); | ||
93 | | | ||
94 | - x = (T *)kmem_cache_alloc(E3,E4); | ||
95 | + x = kmem_cache_zalloc(E3,E4); | ||
96 | | | ||
97 | - x = (T)kmem_cache_alloc(E3,E4); | ||
98 | + x = (T)kmem_cache_zalloc(E3,E4); | ||
99 | | | ||
100 | - x = kmem_alloc(E1,E2); | ||
101 | + x = kmem_zalloc(E1,E2); | ||
102 | | | ||
103 | - x = (T *)kmem_alloc(E1,E2); | ||
104 | + x = kmem_zalloc(E1,E2); | ||
105 | | | ||
106 | - x = (T)kmem_alloc(E1,E2); | ||
107 | + x = (T)kmem_zalloc(E1,E2); | ||
108 | | | ||
109 | - x = devm_kmalloc(E2,E1,E3); | ||
110 | + x = devm_kzalloc(E2,E1,E3); | ||
111 | | | ||
112 | - x = (T *)devm_kmalloc(E2,E1,E3); | ||
113 | + x = devm_kzalloc(E2,E1,E3); | ||
114 | | | ||
115 | - x = (T)devm_kmalloc(E2,E1,E3); | ||
116 | + x = (T)devm_kzalloc(E2,E1,E3); | ||
117 | | | ||
118 | - x = kvmalloc(E1,E2); | ||
119 | + x = kvzalloc(E1,E2); | ||
120 | | | ||
121 | - x = (T *)kvmalloc(E1,E2); | ||
122 | + x = kvzalloc(E1,E2); | ||
123 | | | ||
124 | - x = (T)kvmalloc(E1,E2); | ||
125 | + x = (T)kvzalloc(E1,E2); | ||
126 | | | ||
127 | - x = pci_alloc_consistent(E2,E1,E3); | ||
128 | + x = pci_zalloc_consistent(E2,E1,E3); | ||
129 | | | ||
130 | - x = (T *)pci_alloc_consistent(E2,E1,E3); | ||
131 | + x = pci_zalloc_consistent(E2,E1,E3); | ||
132 | | | ||
133 | - x = (T)pci_alloc_consistent(E2,E1,E3); | ||
134 | + x = (T)pci_zalloc_consistent(E2,E1,E3); | ||
135 | | | ||
136 | - x = kvmalloc_node(E1,E2,E3); | ||
137 | + x = kvzalloc_node(E1,E2,E3); | ||
138 | | | ||
139 | - x = (T *)kvmalloc_node(E1,E2,E3); | ||
140 | + x = kvzalloc_node(E1,E2,E3); | ||
141 | | | ||
142 | - x = (T)kvmalloc_node(E1,E2,E3); | ||
143 | + x = (T)kvzalloc_node(E1,E2,E3); | ||
144 | ) | ||
145 | if ((x==NULL) || ...) S | ||
146 | - memset((T2)x,0,E1); | ||
147 | |||
148 | //---------------------------------------------------------- | ||
149 | // For org mode | ||
150 | //---------------------------------------------------------- | ||
151 | |||
152 | @r depends on org || report@ | ||
153 | type T, T2; | ||
154 | expression x; | ||
155 | expression E1,E2; | ||
156 | statement S; | ||
157 | position p; | ||
158 | @@ | ||
159 | |||
160 | x = (T)kmalloc@p(E1,E2); | ||
161 | if ((x==NULL) || ...) S | ||
162 | memset((T2)x,0,E1); | ||
163 | |||
164 | @script:python depends on org@ | ||
165 | p << r.p; | ||
166 | x << r.x; | ||
167 | @@ | ||
168 | |||
169 | msg="%s" % (x) | ||
170 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
171 | coccilib.org.print_todo(p[0], msg_safe) | ||
172 | |||
173 | @script:python depends on report@ | ||
174 | p << r.p; | ||
175 | x << r.x; | ||
176 | @@ | ||
177 | |||
178 | msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x) | ||
179 | coccilib.report.print_report(p[0], msg) | ||
180 | |||
181 | //----------------------------------------------------------------- | ||
182 | @r1 depends on org || report@ | ||
183 | type T, T2; | ||
184 | expression x; | ||
185 | expression E1; | ||
186 | statement S; | ||
187 | position p; | ||
188 | @@ | ||
189 | |||
190 | x = (T)vmalloc@p(E1); | ||
191 | if ((x==NULL) || ...) S | ||
192 | memset((T2)x,0,E1); | ||
193 | |||
194 | @script:python depends on org@ | ||
195 | p << r1.p; | ||
196 | x << r1.x; | ||
197 | @@ | ||
198 | |||
199 | msg="%s" % (x) | ||
200 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
201 | coccilib.org.print_todo(p[0], msg_safe) | ||
202 | |||
203 | @script:python depends on report@ | ||
204 | p << r1.p; | ||
205 | x << r1.x; | ||
206 | @@ | ||
207 | |||
208 | msg="WARNING: vzalloc should be used for %s, instead of vmalloc/memset" % (x) | ||
209 | coccilib.report.print_report(p[0], msg) | ||
210 | |||
211 | //----------------------------------------------------------------- | ||
212 | @r2 depends on org || report@ | ||
213 | type T, T2; | ||
214 | expression x; | ||
215 | expression E1,E2,E3,E4; | ||
216 | statement S; | ||
217 | position p; | ||
218 | @@ | ||
219 | |||
220 | x = (T)dma_alloc_coherent@p(E2,E1,E3,E4); | ||
221 | if ((x==NULL) || ...) S | ||
222 | memset((T2)x,0,E1); | ||
223 | |||
224 | @script:python depends on org@ | ||
225 | p << r2.p; | ||
226 | x << r2.x; | ||
227 | @@ | ||
228 | |||
229 | msg="%s" % (x) | ||
230 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
231 | coccilib.org.print_todo(p[0], msg_safe) | ||
232 | |||
233 | @script:python depends on report@ | ||
234 | p << r2.p; | ||
235 | x << r2.x; | ||
236 | @@ | ||
237 | |||
238 | msg="WARNING: dma_zalloc_coherent should be used for %s, instead of dma_alloc_coherent/memset" % (x) | ||
239 | coccilib.report.print_report(p[0], msg) | ||
240 | |||
241 | //----------------------------------------------------------------- | ||
242 | @r3 depends on org || report@ | ||
243 | type T, T2; | ||
244 | expression x; | ||
245 | expression E1,E2,E3; | ||
246 | statement S; | ||
247 | position p; | ||
248 | @@ | ||
249 | |||
250 | x = (T)kmalloc_node@p(E1,E2,E3); | ||
251 | if ((x==NULL) || ...) S | ||
252 | memset((T2)x,0,E1); | ||
253 | |||
254 | @script:python depends on org@ | ||
255 | p << r3.p; | ||
256 | x << r3.x; | ||
257 | @@ | ||
258 | |||
259 | msg="%s" % (x) | ||
260 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
261 | coccilib.org.print_todo(p[0], msg_safe) | ||
262 | |||
263 | @script:python depends on report@ | ||
264 | p << r3.p; | ||
265 | x << r3.x; | ||
266 | @@ | ||
267 | |||
268 | msg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x) | ||
269 | coccilib.report.print_report(p[0], msg) | ||
270 | |||
271 | //----------------------------------------------------------------- | ||
272 | @r4 depends on org || report@ | ||
273 | type T, T2; | ||
274 | expression x; | ||
275 | expression E1,E2,E3; | ||
276 | statement S; | ||
277 | position p; | ||
278 | @@ | ||
279 | |||
280 | x = (T)kmem_cache_alloc@p(E2,E3); | ||
281 | if ((x==NULL) || ...) S | ||
282 | memset((T2)x,0,E1); | ||
283 | |||
284 | @script:python depends on org@ | ||
285 | p << r4.p; | ||
286 | x << r4.x; | ||
287 | @@ | ||
288 | |||
289 | msg="%s" % (x) | ||
290 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
291 | coccilib.org.print_todo(p[0], msg_safe) | ||
292 | |||
293 | @script:python depends on report@ | ||
294 | p << r4.p; | ||
295 | x << r4.x; | ||
296 | @@ | ||
297 | |||
298 | msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x) | ||
299 | coccilib.report.print_report(p[0], msg) | ||
300 | |||
301 | //----------------------------------------------------------------- | ||
302 | @r5 depends on org || report@ | ||
303 | type T, T2; | ||
304 | expression x; | ||
305 | expression E1,E2; | ||
306 | statement S; | ||
307 | position p; | ||
308 | @@ | ||
309 | |||
310 | x = (T)kmem_alloc@p(E1,E2); | ||
311 | if ((x==NULL) || ...) S | ||
312 | memset((T2)x,0,E1); | ||
313 | |||
314 | @script:python depends on org@ | ||
315 | p << r5.p; | ||
316 | x << r5.x; | ||
317 | @@ | ||
318 | |||
319 | msg="%s" % (x) | ||
320 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
321 | coccilib.org.print_todo(p[0], msg_safe) | ||
322 | |||
323 | @script:python depends on report@ | ||
324 | p << r5.p; | ||
325 | x << r5.x; | ||
326 | @@ | ||
327 | |||
328 | msg="WARNING: kmem_zalloc should be used for %s, instead of kmem_alloc/memset" % (x) | ||
329 | coccilib.report.print_report(p[0], msg) | ||
330 | |||
331 | //----------------------------------------------------------------- | ||
332 | @r6 depends on org || report@ | ||
333 | type T, T2; | ||
334 | expression x; | ||
335 | expression E1,E2,E3; | ||
336 | statement S; | ||
337 | position p; | ||
338 | @@ | ||
339 | |||
340 | x = (T)devm_kmalloc@p(E2,E1,E3); | ||
341 | if ((x==NULL) || ...) S | ||
342 | memset((T2)x,0,E1); | ||
343 | |||
344 | @script:python depends on org@ | ||
345 | p << r6.p; | ||
346 | x << r6.x; | ||
347 | @@ | ||
348 | |||
349 | msg="%s" % (x) | ||
350 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
351 | coccilib.org.print_todo(p[0], msg_safe) | ||
352 | |||
353 | @script:python depends on report@ | ||
354 | p << r6.p; | ||
355 | x << r6.x; | ||
356 | @@ | ||
357 | |||
358 | msg="WARNING: devm_kzalloc should be used for %s, instead of devm_kmalloc/memset" % (x) | ||
359 | coccilib.report.print_report(p[0], msg) | ||
360 | |||
361 | //----------------------------------------------------------------- | ||
362 | @r7 depends on org || report@ | ||
363 | type T, T2; | ||
364 | expression x; | ||
365 | expression E1,E2; | ||
366 | statement S; | ||
367 | position p; | ||
368 | @@ | ||
369 | |||
370 | x = (T)kvmalloc@p(E1,E2); | ||
371 | if ((x==NULL) || ...) S | ||
372 | memset((T2)x,0,E1); | ||
373 | |||
374 | @script:python depends on org@ | ||
375 | p << r7.p; | ||
376 | x << r7.x; | ||
377 | @@ | ||
378 | |||
379 | msg="%s" % (x) | ||
380 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
381 | coccilib.org.print_todo(p[0], msg_safe) | ||
382 | |||
383 | @script:python depends on report@ | ||
384 | p << r7.p; | ||
385 | x << r7.x; | ||
386 | @@ | ||
387 | |||
388 | msg="WARNING: kvzalloc should be used for %s, instead of kvmalloc/memset" % (x) | ||
389 | coccilib.report.print_report(p[0], msg) | ||
390 | |||
391 | //----------------------------------------------------------------- | ||
392 | @r8 depends on org || report@ | ||
393 | type T, T2; | ||
394 | expression x; | ||
395 | expression E1,E2,E3; | ||
396 | statement S; | ||
397 | position p; | ||
398 | @@ | ||
399 | |||
400 | x = (T)pci_alloc_consistent@p(E2,E1,E3); | ||
401 | if ((x==NULL) || ...) S | ||
402 | memset((T2)x,0,E1); | ||
403 | |||
404 | @script:python depends on org@ | ||
405 | p << r8.p; | ||
406 | x << r8.x; | ||
407 | @@ | ||
408 | |||
409 | msg="%s" % (x) | ||
410 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
411 | coccilib.org.print_todo(p[0], msg_safe) | ||
412 | |||
413 | @script:python depends on report@ | ||
414 | p << r8.p; | ||
415 | x << r8.x; | ||
416 | @@ | ||
417 | |||
418 | msg="WARNING: pci_zalloc_consistent should be used for %s, instead of pci_alloc_consistent/memset" % (x) | ||
419 | coccilib.report.print_report(p[0], msg) | ||
420 | //----------------------------------------------------------------- | ||
421 | @r9 depends on org || report@ | ||
422 | type T, T2; | ||
423 | expression x; | ||
424 | expression E1,E2,E3; | ||
425 | statement S; | ||
426 | position p; | ||
427 | @@ | ||
428 | |||
429 | x = (T)kvmalloc_node@p(E1,E2,E3); | ||
430 | if ((x==NULL) || ...) S | ||
431 | memset((T2)x,0,E1); | ||
432 | |||
433 | @script:python depends on org@ | ||
434 | p << r9.p; | ||
435 | x << r9.x; | ||
436 | @@ | ||
437 | |||
438 | msg="%s" % (x) | ||
439 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
440 | coccilib.org.print_todo(p[0], msg_safe) | ||
441 | |||
442 | @script:python depends on report@ | ||
443 | p << r9.p; | ||
444 | x << r9.x; | ||
445 | @@ | ||
446 | |||
447 | msg="WARNING: kvzalloc_node should be used for %s, instead of kvmalloc_node/memset" % (x) | ||
448 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/api/memdup.cocci b/scripts/coccinelle/api/memdup.cocci index 3d1aa71b7579..1249b727644b 100644 --- a/scripts/coccinelle/api/memdup.cocci +++ b/scripts/coccinelle/api/memdup.cocci | |||
@@ -49,7 +49,6 @@ statement S; | |||
49 | @@ | 49 | @@ |
50 | 50 | ||
51 | * to = \(kmalloc@p\|kzalloc@p\)(size,flag); | 51 | * to = \(kmalloc@p\|kzalloc@p\)(size,flag); |
52 | to = kmemdup(from,size,flag); | ||
53 | if (to==NULL || ...) S | 52 | if (to==NULL || ...) S |
54 | * memcpy(to, from, size); | 53 | * memcpy(to, from, size); |
55 | 54 | ||
diff --git a/scripts/coccinelle/free/ifnullfree.cocci b/scripts/coccinelle/free/ifnullfree.cocci index 14a4cd98e83b..a70e123cb12b 100644 --- a/scripts/coccinelle/free/ifnullfree.cocci +++ b/scripts/coccinelle/free/ifnullfree.cocci | |||
@@ -55,5 +55,5 @@ cocci.print_main("NULL check before that freeing function is not needed", p) | |||
55 | p << r.p; | 55 | p << r.p; |
56 | @@ | 56 | @@ |
57 | 57 | ||
58 | msg = "WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values." | 58 | msg = "WARNING: NULL check before some freeing functions is not needed." |
59 | coccilib.report.print_report(p[0], msg) | 59 | coccilib.report.print_report(p[0], msg) |
diff --git a/scripts/coccinelle/misc/array_size.cocci b/scripts/coccinelle/misc/array_size.cocci index 6ec05710b017..09520f0941f0 100644 --- a/scripts/coccinelle/misc/array_size.cocci +++ b/scripts/coccinelle/misc/array_size.cocci | |||
@@ -72,13 +72,13 @@ position p; | |||
72 | (sizeof(E)@p /sizeof(T)) | 72 | (sizeof(E)@p /sizeof(T)) |
73 | ) | 73 | ) |
74 | 74 | ||
75 | @script:python depends on i&&org@ | 75 | @script:python depends on org@ |
76 | p << r.p; | 76 | p << r.p; |
77 | @@ | 77 | @@ |
78 | 78 | ||
79 | coccilib.org.print_todo(p[0], "WARNING should use ARRAY_SIZE") | 79 | coccilib.org.print_todo(p[0], "WARNING should use ARRAY_SIZE") |
80 | 80 | ||
81 | @script:python depends on i&&report@ | 81 | @script:python depends on report@ |
82 | p << r.p; | 82 | p << r.p; |
83 | @@ | 83 | @@ |
84 | 84 | ||
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index c23534925b38..9fbcf5ed0ca7 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
@@ -32,10 +32,14 @@ MKSPEC := $(srctree)/scripts/package/mkspec | |||
32 | 32 | ||
33 | quiet_cmd_src_tar = TAR $(2).tar.gz | 33 | quiet_cmd_src_tar = TAR $(2).tar.gz |
34 | cmd_src_tar = \ | 34 | cmd_src_tar = \ |
35 | set -e; \ | ||
35 | if test "$(objtree)" != "$(srctree)"; then \ | 36 | if test "$(objtree)" != "$(srctree)"; then \ |
36 | echo "Building source tarball is not possible outside the"; \ | 37 | echo >&2; \ |
37 | echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ | 38 | echo >&2 " ERROR:"; \ |
38 | echo "binrpm-pkg or bindeb-pkg target instead."; \ | 39 | echo >&2 " Building source tarball is not possible outside the"; \ |
40 | echo >&2 " kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \ | ||
41 | echo >&2 " binrpm-pkg or bindeb-pkg target instead."; \ | ||
42 | echo >&2; \ | ||
39 | false; \ | 43 | false; \ |
40 | fi ; \ | 44 | fi ; \ |
41 | $(srctree)/scripts/setlocalversion --save-scmversion; \ | 45 | $(srctree)/scripts/setlocalversion --save-scmversion; \ |
@@ -94,6 +98,21 @@ bindeb-pkg: FORCE | |||
94 | 98 | ||
95 | clean-dirs += $(objtree)/debian/ | 99 | clean-dirs += $(objtree)/debian/ |
96 | 100 | ||
101 | # snap-pkg | ||
102 | # --------------------------------------------------------------------------- | ||
103 | snap-pkg: FORCE | ||
104 | rm -rf $(objtree)/snap | ||
105 | mkdir $(objtree)/snap | ||
106 | $(MAKE) clean | ||
107 | $(call cmd,src_tar,$(KERNELPATH)) | ||
108 | sed "s@KERNELRELEASE@$(KERNELRELEASE)@; \ | ||
109 | s@SRCTREE@$(shell realpath $(KERNELPATH).tar.gz)@" \ | ||
110 | $(srctree)/scripts/package/snapcraft.template > \ | ||
111 | $(objtree)/snap/snapcraft.yaml | ||
112 | cd $(objtree)/snap && \ | ||
113 | snapcraft --target-arch=$(UTS_MACHINE) | ||
114 | |||
115 | clean-dirs += $(objtree)/snap/ | ||
97 | 116 | ||
98 | # tarball targets | 117 | # tarball targets |
99 | # --------------------------------------------------------------------------- | 118 | # --------------------------------------------------------------------------- |
@@ -138,6 +157,7 @@ help: FORCE | |||
138 | @echo ' binrpm-pkg - Build only the binary kernel RPM package' | 157 | @echo ' binrpm-pkg - Build only the binary kernel RPM package' |
139 | @echo ' deb-pkg - Build both source and binary deb kernel packages' | 158 | @echo ' deb-pkg - Build both source and binary deb kernel packages' |
140 | @echo ' bindeb-pkg - Build only the binary kernel deb package' | 159 | @echo ' bindeb-pkg - Build only the binary kernel deb package' |
160 | @echo ' snap-pkg - Build only the binary kernel snap package (will connect to external hosts)' | ||
141 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' | 161 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
142 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' | 162 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' |
143 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' | 163 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' |
diff --git a/scripts/package/snapcraft.template b/scripts/package/snapcraft.template new file mode 100644 index 000000000000..626d278e4a5a --- /dev/null +++ b/scripts/package/snapcraft.template | |||
@@ -0,0 +1,14 @@ | |||
1 | name: kernel | ||
2 | version: KERNELRELEASE | ||
3 | summary: Linux kernel | ||
4 | description: The upstream Linux kernel | ||
5 | grade: stable | ||
6 | confinement: strict | ||
7 | type: kernel | ||
8 | |||
9 | parts: | ||
10 | kernel: | ||
11 | plugin: kernel | ||
12 | source: SRCTREE | ||
13 | source-type: tar | ||
14 | kernel-with-firmware: false | ||