From patchwork Thu Sep 10 12:05:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mauro Carvalho Chehab X-Patchwork-Id: 309856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A420C43461 for ; Thu, 10 Sep 2020 12:33:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6856620882 for ; Thu, 10 Sep 2020 12:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599741193; bh=Vy7EZHca0B9LMIZXxYAgS/Ysoz2K5hh6Lt9nthi4Lw4=; h=From:Date:Subject:To:Cc:Reply-to:List-ID:From; b=le3P4kqdz67h65Tfb20XtA7egfxILYMAnKCFOxD8T3tNBiulY6fLwbHWjdLF+/Llw cFbne43qkzfnVwAgxpa9mDxjF9JlsmMTfs2cYlH8970z115JMyG/Gytsx1tFT4pFOA osFupvGIuoZN+9zXCAZG3Qdm/zJRslKBXVn5qOQk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730395AbgIJMdI (ORCPT ); Thu, 10 Sep 2020 08:33:08 -0400 Received: from www.linuxtv.org ([130.149.80.248]:43458 "EHLO www.linuxtv.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbgIJMbB (ORCPT ); Thu, 10 Sep 2020 08:31:01 -0400 Received: from mchehab by www.linuxtv.org with local (Exim 4.92) (envelope-from ) id 1kGLHT-004CA3-5m; Thu, 10 Sep 2020 12:02:23 +0000 From: Mauro Carvalho Chehab Date: Thu, 10 Sep 2020 12:05:10 +0000 Subject: [git:media_tree/fixes] media: cec-adap.c: don't use flush_scheduled_work() To: linuxtv-commits@linuxtv.org Cc: stable@vger.kernel.org, Hans Verkuil Mail-followup-to: linux-media@vger.kernel.org Forward-to: linux-media@vger.kernel.org Reply-to: linux-media@vger.kernel.org Message-Id: Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org This is an automatic generated email to let you know that the following patch were queued: Subject: media: cec-adap.c: don't use flush_scheduled_work() Author: Hans Verkuil Date: Tue Sep 8 12:02:53 2020 +0200 For some inexplicable reason I decided to call flush_scheduled_work() instead of cancel_delayed_work_sync(). The problem with that is that flush_scheduled_work() waits for *all* queued scheduled work to be completed instead of just the work itself. This can cause a deadlock if a CEC driver also schedules work that takes the same lock. See the comments for flush_scheduled_work() in linux/workqueue.h. This is exactly what has been observed a few times. This patch simply replaces flush_scheduled_work() by cancel_delayed_work_sync(). Signed-off-by: Hans Verkuil Cc: # for v5.8 and up Signed-off-by: Mauro Carvalho Chehab drivers/media/cec/core/cec-adap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/cec/core/cec-adap.c b/drivers/media/cec/core/cec-adap.c index 4efe8014445e..926d65db6d3e 100644 --- a/drivers/media/cec/core/cec-adap.c +++ b/drivers/media/cec/core/cec-adap.c @@ -1199,7 +1199,7 @@ void cec_received_msg_ts(struct cec_adapter *adap, /* Cancel the pending timeout work */ if (!cancel_delayed_work(&data->work)) { mutex_unlock(&adap->lock); - flush_scheduled_work(); + cancel_delayed_work_sync(&data->work); mutex_lock(&adap->lock); } /*