From patchwork Fri May 1 13:22:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 226657 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 CE37BC4724C for ; Fri, 1 May 2020 13:34:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A60FE24954 for ; Fri, 1 May 2020 13:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588340055; bh=cnL9i4QD9VSaNR2UsO45mXpYGTQ8qPnpMveOLtulI1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DlpL0Mj68G9IMb39k7Q22Rd6cxoCXCmekMc8228e6eW8OevR9L9/pVHhb1O7Pwczv EuX58GSyK1xIMdItLJVVfvgdFjm2EugEUlVkgAMtNen3j/omoluAB/yHWfkU4fDURC aDT/Ix1KMpdB4nuaJmEt5VmmmUYufQHkYZR4l52I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730093AbgEANeO (ORCPT ); Fri, 1 May 2020 09:34:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:60232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729669AbgEANeL (ORCPT ); Fri, 1 May 2020 09:34:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E413216FD; Fri, 1 May 2020 13:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588340050; bh=cnL9i4QD9VSaNR2UsO45mXpYGTQ8qPnpMveOLtulI1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQbeoRN9ZoJiYIJ9wCouADrfG4pElq8F7UP5czWW7SFX7lcrUghCCh7IUOBjs6G3c eNovKJg3BRe4fCRSrXBM08cYoeDO3Vg3Vr7v8aAaHlXnf/yqaiPUxJa5Osmxls6flk WI7uAhWKjhj5YbPkIghf2FaaQ2Js5Dmh2SGX3y+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yi Huaijie , Liu Jian , Tokunori Ikegami , Richard Weinberger , Guenter Roeck Subject: [PATCH 4.14 086/117] mtd: cfi: fix deadloop in cfi_cmdset_0002.c do_write_buffer Date: Fri, 1 May 2020 15:22:02 +0200 Message-Id: <20200501131554.917192410@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200501131544.291247695@linuxfoundation.org> References: <20200501131544.291247695@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Liu Jian commit d9b8a67b3b95a5c5aae6422b8113adc1c2485f2b upstream. In function do_write_buffer(), in the for loop, there is a case chip_ready() returns 1 while chip_good() returns 0, so it never break the loop. To fix this, chip_good() is enough and it should timeout if it stay bad for a while. Fixes: dfeae1073583("mtd: cfi_cmdset_0002: Change write buffer to check correct value") Signed-off-by: Yi Huaijie Signed-off-by: Liu Jian Reviewed-by: Tokunori Ikegami Signed-off-by: Richard Weinberger Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1883,7 +1883,11 @@ static int __xipram do_write_buffer(stru continue; } - if (time_after(jiffies, timeo) && !chip_ready(map, adr)) + /* + * We check "time_after" and "!chip_good" before checking "chip_good" to avoid + * the failure due to scheduling. + */ + if (time_after(jiffies, timeo) && !chip_good(map, adr, datum)) break; if (chip_good(map, adr, datum)) {