• Mel Gorman's avatar
    swapfile: avoid dereferencing bd_disk during swap_entry_free for network storage · 73744923
    Mel Gorman authored
    Commit b3a27d ("swap: Add swap slot free callback to
    block_device_operations") dereferences p->bdev->bd_disk but this is a NULL
    dereference if using swap-over-NFS.  This patch checks SWP_BLKDEV on the
    swap_info_struct before dereferencing.
    
    With reference to this callback, Christoph Hellwig stated "Please just
    remove the callback entirely.  It has no user outside the staging tree and
    was added clearly against the rules for that staging tree".  This would
    also be my preference but there was not an obvious way of keeping zram in
    staging/ happy.
    Signed-off-by: default avatarXiaotian Feng <dfeng@redhat.com>
    Signed-off-by: default avatarMel Gorman <mgorman@suse.de>
    Acked-by: default avatarRik van Riel <riel@redhat.com>
    Cc: Christoph Hellwig <hch@infradead.org>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Eric B Munson <emunson@mgebm.net>
    Cc: Eric Paris <eparis@redhat.com>
    Cc: James Morris <jmorris@namei.org>
    Cc: Mel Gorman <mgorman@suse.de>
    Cc: Mike Christie <michaelc@cs.wisc.edu>
    Cc: Neil Brown <neilb@suse.de>
    Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
    Cc: Trond Myklebust <Trond.Myklebust@netapp.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    73744923
swapfile.c 63.1 KB