Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752852AbbBMFwJ (ORCPT ); Fri, 13 Feb 2015 00:52:09 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:45517 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752085AbbBMFwH (ORCPT ); Fri, 13 Feb 2015 00:52:07 -0500 From: Wang Nan To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , Subject: [RFC PATCH v3 05/26] ftrace/x86: Ensure rec->flags no change when failure occures. Date: Fri, 13 Feb 2015 13:40:29 +0800 Message-ID: <1423806029-61699-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> References: <1423805941-61407-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.197.247] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1365 Lines: 49 Don't change rec->flags if code modification fails. Signed-off-by: Wang Nan --- arch/x86/kernel/ftrace.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 8b7b0a5..7bdba65 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -497,6 +497,7 @@ static int finish_update(struct dyn_ftrace *rec, int enable) { unsigned long ftrace_addr; int ret; + unsigned long old_flags = rec->flags; ret = ftrace_update_record(rec, enable); @@ -509,14 +510,18 @@ static int finish_update(struct dyn_ftrace *rec, int enable) case FTRACE_UPDATE_MODIFY_CALL: case FTRACE_UPDATE_MAKE_CALL: /* converting nop to call */ - return finish_update_call(rec, ftrace_addr); + ret = finish_update_call(rec, ftrace_addr); + break; case FTRACE_UPDATE_MAKE_NOP: /* converting a call to a nop */ - return finish_update_nop(rec); + ret = finish_update_nop(rec); + break; } - return 0; + if (ret) + rec->flags = old_flags; + return ret; } static void do_sync_core(void *data) -- 1.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/