Whamcloud - gitweb
LU-3238 ptlrpc: expression expansion bug in macro
authorLiang Zhen <liang.zhen@intel.com>
Sun, 28 Apr 2013 08:51:52 +0000 (16:51 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 29 Apr 2013 16:20:35 +0000 (12:20 -0400)
slab flag passed into __OBD_SLAB_ALLOC_VERBOSE is not bracketed,
so __OBD_SLAB_ALLOC_VERBOSE will get wrong value from unexpected
expression expansion and hit assertion.

Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Change-Id: I4f09ccf743d6bda765bab64c60801a87d9a6b9b5
Reviewed-on: http://review.whamcloud.com/6190
Tested-by: Hudson
Reviewed-by: Nikitas Angelinas <nikitas_angelinas@xyratex.com>
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/include/obd_support.h
lustre/ptlrpc/nrs_orr.c

index 5c44cfb..8c7e4ac 100644 (file)
@@ -782,7 +782,7 @@ do {                                                                              \
 
 #define __OBD_SLAB_ALLOC_VERBOSE(ptr, slab, cptab, cpt, size, type)          \
 do {                                                                         \
-        LASSERT(ergo(type != CFS_ALLOC_ATOMIC, !cfs_in_interrupt()));         \
+       LASSERT(ergo((type) != CFS_ALLOC_ATOMIC, !cfs_in_interrupt()));       \
        (ptr) = (cptab) == NULL ?                                             \
                cfs_mem_cache_alloc(slab, type) :                             \
                cfs_mem_cache_cpt_alloc(slab, cptab, cpt, type);              \
index c660916..9af1564 100644 (file)
@@ -884,8 +884,8 @@ int nrs_orr_res_get(struct ptlrpc_nrs_policy *policy,
 
        OBD_SLAB_CPT_ALLOC_PTR_GFP(orro, orrd->od_cache,
                                   nrs_pol2cptab(policy), nrs_pol2cptid(policy),
-                                  moving_req ? CFS_ALLOC_ATOMIC :
-                                  CFS_ALLOC_IO);
+                                  (moving_req ? CFS_ALLOC_ATOMIC :
+                                   CFS_ALLOC_IO));
        if (orro == NULL)
                RETURN(-ENOMEM);