Commit f42158fe6785dd366073c7fd00f159a65c631597

Authored by Konrad Rzeszutek Wilk
Committed by Linus Torvalds
1 parent 10a7a07713

zcache/tmem: Better error checking on frontswap_register_ops return value.

In the past it either used to be NULL or the "older" backend. Now we
also return -Exx error codes.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: Andor Daam <andor.daam@googlemail.com>
Cc: Dan Magenheimer <dan.magenheimer@oracle.com>
Cc: Florian Schmaus <fschmaus@gmail.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Stefan Hengelein <ilendir@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 2 changed files with 8 additions and 2 deletions Side-by-side Diff

drivers/staging/zcache/zcache-main.c
... ... @@ -1886,8 +1886,11 @@
1886 1886 namestr, frontswap_has_exclusive_gets,
1887 1887 !disable_frontswap_ignore_nonactive);
1888 1888 #endif
1889   - if (old_ops != NULL)
  1889 + if (IS_ERR(old_ops) || old_ops) {
  1890 + if (IS_ERR(old_ops))
  1891 + return PTR_RET(old_ops);
1890 1892 pr_warn("%s: frontswap_ops overridden\n", namestr);
  1893 + }
1891 1894 }
1892 1895 if (ramster_enabled)
1893 1896 ramster_init(!disable_cleancache, !disable_frontswap,
... ... @@ -397,8 +397,11 @@
397 397 frontswap_register_ops(&tmem_frontswap_ops);
398 398  
399 399 tmem_frontswap_poolid = -1;
400   - if (old_ops)
  400 + if (IS_ERR(old_ops) || old_ops) {
  401 + if (IS_ERR(old_ops))
  402 + return PTR_ERR(old_ops);
401 403 s = " (WARNING: frontswap_ops overridden)";
  404 + }
402 405 printk(KERN_INFO "frontswap enabled, RAM provided by "
403 406 "Xen Transcendent Memory%s\n", s);
404 407 }