From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752330AbbCIEnR (ORCPT ); Mon, 9 Mar 2015 00:43:17 -0400 Received: from mga01.intel.com ([192.55.52.88]:17597 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752261AbbCIEnP convert rfc822-to-8bit (ORCPT ); Mon, 9 Mar 2015 00:43:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,365,1422950400"; d="scan'208,223";a="464440126" From: "Du, Changbin" To: Tejun Heo CC: "linux-kernel@vger.kernel.org" Subject: [PATCH] workqueue: detect uninitated work_struct and BUG() if true Thread-Topic: [PATCH] workqueue: detect uninitated work_struct and BUG() if true Thread-Index: AdBaI1yW6nMH7HUnRzyBk9sYhfyxOQ== Date: Mon, 9 Mar 2015 04:43:11 +0000 Message-ID: <0C18FE92A7765D4EB9EE5D38D86A563A01C85B55@SHSMSX103.ccr.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >>From cdebb88ac0fb3f900ef28f28ccb4a12159c295db Mon Sep 17 00:00:00 2001 From: "Du, Changbin" Date: Mon, 9 Mar 2015 12:06:43 +0800 Subject: [PATCH] workqueue: detect uninitated work_struct and BUG() if true Recently I encounter a driver issue that caused by missing initializing the work_struct. Then the work never get executed and stay in workqueue forever. This take me some time to locate the error. This issue can be seen early if detect it when queuing a work. Signed-off-by: Du, Changbin --- kernel/workqueue.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/workqueue.c b/kernel/workqueue.c index f288493..5c1a5bc 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -1295,6 +1295,9 @@ static void __queue_work(int cpu, struct workqueue_struct *wq, */ WARN_ON_ONCE(!irqs_disabled()); + if (!work->func) + BUG(); + debug_work_activate(work); /* if draining, only works from the same workqueue are allowed */ -- 1.9.1