Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1951356ybv; Fri, 14 Feb 2020 08:46:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyD81QsT/ZhE9Mqy93JFDosv9JVnTpJSei63q+lrvm/ST1Kg6avatslS6DMXhnELJLNgFC7 X-Received: by 2002:a05:6808:24e:: with SMTP id m14mr2546769oie.168.1581698763491; Fri, 14 Feb 2020 08:46:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698763; cv=none; d=google.com; s=arc-20160816; b=LSpaWD3BLg/g6cHqtJhOP/pp510esAETA5LY9BvGaaWu9aa6JzD7Bo4dNKIVSE5w2r z8R+/lYwEi4apamb1akSREWlWRa1upmZRWxy5ZSe1MZ6N2O8ybt/uvj0vEKQ/YwqIS0U 91Wriw9MkK46dfOzfg3qBBxxxSVgzLdhIPUK0FT/4ZEm0NLKaO2UJKNJJ541TJKiI6Cr efqDRItuTsNKxiMl9kTX5MnXlhaiRVLRK67Bte/oO92co4Iv9cxHVWQ4EYtD9yX7igcu tuN8s/ePmhlYfv8Tn1rv619xr3CcQTWdYjnP4vT45ClhIHxcEuIIo6P0zWzq7JvHWqH1 APzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=A66vw6uU/WIvSKmUzwWw7AcDvgWqFKaDd8iwo5Jvchc=; b=NW5sqFqIC3E90ej0MJpC8wems5K+D3GMCNEj/c58kDl4KIDwurKSORR20E//6zLcKM jg01n3qHoVrA86plkNFAhCS0Tq+K9sb19+Sk1l/RcueqEg2+m+6FUeOwEfKvq1eMASXj gVuqgPyYjaTq18uxWuDfFvRYcEhrQf0w04gO85Yj64L1FPXK9/mcyTS3K0Zo/V44gWWK 0LJfEnlqzaeZX/IvzETtiKEvWcJO4y5IYXY5hGz2zRfMU3xWF2WaBwBfuXMAPQYCU46p A5rFc36etUkRfKiFQl7rwzB0s71Oz30A73j9jYu+IfR+YJ1TMCEspKd54ZpqyygZ5ido v5Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0pT4XwF5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i23si3027642oto.206.2020.02.14.08.45.51; Fri, 14 Feb 2020 08:46:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0pT4XwF5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404032AbgBNQoL (ORCPT + 99 others); Fri, 14 Feb 2020 11:44:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:56496 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393057AbgBNQVl (ORCPT ); Fri, 14 Feb 2020 11:21:41 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02B9F246BE; Fri, 14 Feb 2020 16:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697300; bh=i4rCMs/KdszCUrhFYZjd38y7vAH2KN/V466RTKcmpKo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0pT4XwF5QF22C0nhsfVtFfRcDAzXq5hr8XV0U0H5LPKyhscCvrULjdlDRNH2UewWQ GTC6I7NzL9nxxIs1ExRM5GOhAz0RsHdRi2FdVwgt3mo/jqXTs7qznHW+3MwoAiIMtS SodwisEGLLAha4FCy1EEGbLvKsl6fYSrUAxY/5iY= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jia-Ju Bai , Fabien Dessenne , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 014/141] media: sti: bdisp: fix a possible sleep-in-atomic-context bug in bdisp_device_run() Date: Fri, 14 Feb 2020 11:19:14 -0500 Message-Id: <20200214162122.19794-14-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit bb6d42061a05d71dd73f620582d9e09c8fbf7f5b ] The driver may sleep while holding a spinlock. The function call path (from bottom to top) in Linux 4.19 is: drivers/media/platform/sti/bdisp/bdisp-hw.c, 385: msleep in bdisp_hw_reset drivers/media/platform/sti/bdisp/bdisp-v4l2.c, 341: bdisp_hw_reset in bdisp_device_run drivers/media/platform/sti/bdisp/bdisp-v4l2.c, 317: _raw_spin_lock_irqsave in bdisp_device_run To fix this bug, msleep() is replaced with udelay(). This bug is found by a static analysis tool STCheck written by myself. Signed-off-by: Jia-Ju Bai Reviewed-by: Fabien Dessenne Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/sti/bdisp/bdisp-hw.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/sti/bdisp/bdisp-hw.c b/drivers/media/platform/sti/bdisp/bdisp-hw.c index b7892f3efd988..5c4c3f0c57be1 100644 --- a/drivers/media/platform/sti/bdisp/bdisp-hw.c +++ b/drivers/media/platform/sti/bdisp/bdisp-hw.c @@ -14,8 +14,8 @@ #define MAX_SRC_WIDTH 2048 /* Reset & boot poll config */ -#define POLL_RST_MAX 50 -#define POLL_RST_DELAY_MS 20 +#define POLL_RST_MAX 500 +#define POLL_RST_DELAY_MS 2 enum bdisp_target_plan { BDISP_RGB, @@ -382,7 +382,7 @@ int bdisp_hw_reset(struct bdisp_dev *bdisp) for (i = 0; i < POLL_RST_MAX; i++) { if (readl(bdisp->regs + BLT_STA1) & BLT_STA1_IDLE) break; - msleep(POLL_RST_DELAY_MS); + udelay(POLL_RST_DELAY_MS * 1000); } if (i == POLL_RST_MAX) dev_err(bdisp->dev, "Reset timeout\n"); -- 2.20.1