Commit 9b29972
bcache: cleaned up error handling around register_cache()
Fix null pointer dereference by changing register_cache() to return an int
instead of being void. This allows it to return -ENOMEM or -ENODEV and
enables upper layers to handle the OOM case without NULL pointer issues.
See this thread:
http://thread.gmane.org/gmane.linux.kernel.bcache.devel/3521
Fixes this error:
gargamel:/sys/block/md5/bcache# echo /dev/sdh2 > /sys/fs/bcache/register
bcache: register_cache() error opening sdh2: cannot allocate memory
BUG: unable to handle kernel NULL pointer dereference at 00000000000009b8
IP: [<ffffffffc05a7e8d>] cache_set_flush+0x102/0x15c [bcache]
PGD 120dff067 PUD 1119a3067 PMD 0
Oops: 0000 [#1] SMP
Modules linked in: veth ip6table_filter ip6_tables
(...)
CPU: 4 PID: 3371 Comm: kworker/4:3 Not tainted 4.4.2-amd64-i915-volpreempt-20160213bc1 #3
Hardware name: System manufacturer System Product Name/P8H67-M PRO, BIOS 3904 04/27/2013
Workqueue: events cache_set_flush [bcache]
task: ffff88020d5dc280 ti: ffff88020b6f8000 task.ti: ffff88020b6f8000
RIP: 0010:[<ffffffffc05a7e8d>] [<ffffffffc05a7e8d>] cache_set_flush+0x102/0x15c [bcache]
Signed-off-by: Eric Wheeler <bcache@linux.ewheeler.net>
Tested-by: Marc MERLIN <marc@merlins.org>
Cc: <stable@vger.kernel.org>1 parent 07cc6ef commit 9b29972
1 file changed
+22
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1835 | 1835 | | |
1836 | 1836 | | |
1837 | 1837 | | |
1838 | | - | |
| 1838 | + | |
1839 | 1839 | | |
1840 | 1840 | | |
1841 | 1841 | | |
1842 | | - | |
| 1842 | + | |
| 1843 | + | |
1843 | 1844 | | |
1844 | 1845 | | |
1845 | 1846 | | |
| |||
1854 | 1855 | | |
1855 | 1856 | | |
1856 | 1857 | | |
1857 | | - | |
| 1858 | + | |
| 1859 | + | |
1858 | 1860 | | |
1859 | 1861 | | |
1860 | | - | |
1861 | | - | |
1862 | | - | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
1863 | 1867 | | |
1864 | 1868 | | |
1865 | 1869 | | |
1866 | 1870 | | |
1867 | 1871 | | |
1868 | | - | |
1869 | | - | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
1870 | 1876 | | |
1871 | 1877 | | |
| 1878 | + | |
1872 | 1879 | | |
1873 | 1880 | | |
1874 | | - | |
| 1881 | + | |
1875 | 1882 | | |
1876 | | - | |
1877 | | - | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
1878 | 1887 | | |
1879 | 1888 | | |
1880 | 1889 | | |
| |||
1972 | 1981 | | |
1973 | 1982 | | |
1974 | 1983 | | |
1975 | | - | |
| 1984 | + | |
| 1985 | + | |
1976 | 1986 | | |
1977 | 1987 | | |
1978 | 1988 | | |
| |||
0 commit comments