lkml.org 
[lkml]   [2010]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[PATCH -mmotm 29/30] fix null pointer deref in swap_entry_free
    From ea7b13006f42f7dcadd1bfb874d5e525b4c259e3 Mon Sep 17 00:00:00 2001
    From: Xiaotian Feng <dfeng@redhat.com>
    Date: Tue, 13 Jul 2010 13:44:08 +0800
    Subject: [PATCH 29/30] fix null pointer deref in swap_entry_free

    Commit b3a27d uses p->bdev->bd_disk, this will lead a null pointer
    deref with swap over nfs.

    Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
    ---
    mm/swapfile.c | 9 +++++----
    1 files changed, 5 insertions(+), 4 deletions(-)

    diff --git a/mm/swapfile.c b/mm/swapfile.c
    index d8a05e4..3eb53fc 100644
    --- a/mm/swapfile.c
    +++ b/mm/swapfile.c
    @@ -577,7 +577,6 @@ static unsigned char swap_entry_free(struct swap_info_struct *p,

    /* free if no reference */
    if (!usage) {
    - struct gendisk *disk = p->bdev->bd_disk;
    if (offset < p->lowest_bit)
    p->lowest_bit = offset;
    if (offset > p->highest_bit)
    @@ -587,9 +586,11 @@ static unsigned char swap_entry_free(struct swap_info_struct *p,
    swap_list.next = p->type;
    nr_swap_pages++;
    p->inuse_pages--;
    - if ((p->flags & SWP_BLKDEV) &&
    - disk->fops->swap_slot_free_notify)
    - disk->fops->swap_slot_free_notify(p->bdev, offset);
    + if (p->flags & SWP_BLKDEV) {
    + struct gendisk *disk = p->bdev->bd_disk;
    + if (disk->fops->swap_slot_free_notify)
    + disk->fops->swap_slot_free_notify(p->bdev, offset);
    + }
    }

    return usage;
    --
    1.7.1.1


    \
     
     \ /
      Last update: 2010-07-13 12:35    [W:0.019 / U:119.488 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site