VirtualBox

忽略:
時間撮記:
2011-2-4 下午03:11:11 (14 年 以前)
作者:
vboxsync
訊息:

Linux Additions / shared folders: fix possible memory leak in error case

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Additions/linux/sharedfolders/lnkops.c

    r35472 r35854  
    2323static void *sf_follow_link(struct dentry *dentry, struct nameidata *nd)
    2424{
    25         struct inode *inode = dentry->d_inode;
    26         struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb);
    27         struct sf_inode_info *sf_i = GET_INODE_INFO(inode);
    28         int error = -ENOMEM;
    29         unsigned long page = get_zeroed_page(GFP_KERNEL);
    30         int rc;
     25    struct inode *inode = dentry->d_inode;
     26    struct sf_glob_info *sf_g = GET_GLOB_INFO(inode->i_sb);
     27    struct sf_inode_info *sf_i = GET_INODE_INFO(inode);
     28    int error = -ENOMEM;
     29    char *path = (char*)get_zeroed_page(GFP_KERNEL);
     30    int rc;
    3131
    32         if (page)
     32    if (path)
     33    {
     34        error = 0;
     35        rc = vboxReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, path);
     36        if (RT_FAILURE(rc))
    3337        {
    34                 error = 0;
    35                 rc = vboxReadLink(&client_handle, &sf_g->map, sf_i->path, PATH_MAX, (char *)page);
    36                 if (RT_FAILURE(rc))
    37                 {
    38                         LogFunc(("vboxReadLink failed, caller=%s, rc=%Rrc\n",
    39                                  __func__, rc));
    40                         error = -EPROTO;
    41                 }
     38            LogFunc(("vboxReadLink failed, caller=%s, rc=%Rrc\n", __func__, rc));
     39            free_page((unsigned long)path);
     40            error = -EPROTO;
    4241        }
    43         nd_set_link(nd, error ? ERR_PTR(error) : (char *)page);
    44         return NULL;
     42    }
     43    nd_set_link(nd, error ? ERR_PTR(error) : path);
     44    return NULL;
    4545}
    4646
    4747static void sf_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
    4848{
    49         char *page = nd_get_link(nd);
    50         if (!IS_ERR(page))
    51                 free_page((unsigned long)page);
     49    char *page = nd_get_link(nd);
     50    if (!IS_ERR(page))
     51        free_page((unsigned long)page);
    5252}
    5353
    5454struct inode_operations sf_lnk_iops =
    5555{
    56         .readlink       = generic_readlink,
    57         .follow_link    = sf_follow_link,
    58         .put_link       = sf_put_link
     56    .readlink       = generic_readlink,
     57    .follow_link    = sf_follow_link,
     58    .put_link       = sf_put_link
    5959};
    6060
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette