This commit makes the kfree_rcu() macro's semantics be consistent with the likes of kfree() by adding a check for NULL pointers, so that kfree_rcu(NULL, ...) is a no-op.
Unified · Split
| @@ -805,7 +805,7 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) · 804 unmodified lines | |||
| 805 | /** | 805 | /** |
| 806 | * kfree_rcu() - kfree an object after a grace period. | 806 | * kfree_rcu() - kfree an object after a grace period. |
| 807 | * @ptr: pointer to kfree | 807 | * @ptr: pointer to kfree |
| 808 | * @rcu_head: the name of the struct rcu_head within the type of @ptr. | 808 | * @rhf: the name of the struct rcu_head within the type of @ptr. |
| 809 | * | 809 | * |
| 810 | * Many rcu callbacks functions just call kfree() on the base structure. | 810 | * Many rcu callbacks functions just call kfree() on the base structure. |
| 811 | * These functions are trivial, but their size adds up, and furthermore | 811 | * These functions are trivial, but their size adds up, and furthermore |
| @@ -828,9 +828,13 @@ static inline notrace void rcu_read_unlock_sched_notrace(void) · 16 unmodified lines | |||
| 828 | * The BUILD_BUG_ON check must not involve any function calls, hence the | 828 | * The BUILD_BUG_ON check must not involve any function calls, hence the |
| 829 | * checks are done in macros here. | 829 | * checks are done in macros here. |
| 830 | */ | 830 | */ |
| 831 | #define kfree_rcu(ptr, rcu_head) \ | 831 | #define kfree_rcu(ptr, rhf) \ |
| 832 | __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) | 832 | do { \ |
| 833 | 833 | typeof (ptr) ___p = (ptr); \ | |
| 834 | \ | ||
| 835 | if (___p) \ | ||
| 836 | __kfree_rcu(&((___p)->rhf), offsetof(typeof(*(ptr)), rhf)); \ | ||
| 837 | } while (0) | ||
| 834 | 838 | ||
| 835 | /* | 839 | /* |
| 836 | * Place this after a lock-acquisition primitive to guarantee that | 840 | * Place this after a lock-acquisition primitive to guarantee that |