Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5413876img; Wed, 27 Mar 2019 08:06:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+MFOC0E544qTD4qHeX4+mDTBgt8IMw/t7xS3+36WTwoAvlXM0zDuY8k5WsN71/CcUKEQG X-Received: by 2002:a62:4610:: with SMTP id t16mr36696790pfa.217.1553699203254; Wed, 27 Mar 2019 08:06:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553699203; cv=none; d=google.com; s=arc-20160816; b=ZS6lb8KD17O8bNTUubBzdY93+iBRScwomBTkIUxfizeaaZcK1ILxvJvgHFFEcgnJp+ Sv4BXgLeo7gwLU0Fr7r9a4pCnacHi+ZH4p+NbhnL7WZ8phRN5GSQcvlq2joe0BMYF6CU etNx8Ykqrjhu46NYgKqpDLTuJi5zLKEd1TEuwcLWeDgDqXaus2eoyVrtlraW0uBQFdqd Fwf2+9+92InnpaqfH4fHf3boUH1woQL12Z/nNWJgnd6diyrCDdY1N3HvXeiCK1TFGi9v H0PiHaNEs/Szxa23LvPLLkGTQz5YpywIIAndXIzs6IRD1mX3556eTGF/2ZGv9kZfpFv2 6dSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=KlOWqPcQUdo9+JviwsOXjsYTiOLeHhpwejBsv1GUX50=; b=GnHiu3H/i0Qi7ednKcxr+79GqD3GCyqT9w40xL7dDof/6RBjzIgxWIF53yAuPEMNwY /XW+A1R1UTaw5u+ZQcF/ozoBc5JrlbrWn9QL9EH8bqvyTC11NW3Yq8+tGhprfkyjir6g tDUr/Ehh+S76l0JeBR/LQWQNinZS9zQdP3Mgg27lfSVAmOaVXkvD7bQawXOncIyjXsa7 s9oa9t2IIzBq0gHjNHh7OV3wp4FXFfOxh7VSxxGGJHGcmQwDdU3mPHJqHhJmO6x4Ciis ppZKBuBmD3FwwrNnrFAGw13ACFWOxBCyT9BCNuwLDwZPNuGnNpJI8U/RnEQWcUeUqQgk B6iQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 193si18530545pgc.365.2019.03.27.08.06.27; Wed, 27 Mar 2019 08:06:43 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728535AbfC0PFp (ORCPT + 99 others); Wed, 27 Mar 2019 11:05:45 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5196 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725764AbfC0PFp (ORCPT ); Wed, 27 Mar 2019 11:05:45 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 9E900C02DB1BED3E7BE3; Wed, 27 Mar 2019 23:05:39 +0800 (CST) Received: from huawei.com (10.175.104.208) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.408.0; Wed, 27 Mar 2019 23:05:29 +0800 From: Liu Jian To: , , , , , , , , CC: , , Subject: [PATCH v4] mtd: cfi: fix deadloop in cfi_cmdset_0002.c do_write_buffer Date: Wed, 27 Mar 2019 23:03:53 +0800 Message-ID: <1553699033-103289-1-git-send-email-liujian56@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.208] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 not good status 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 --- v3-v4: 1. add "mtd: " prefix to subject 2. add some comment suggested by reviewers I forgot to resend this patch, I am very sorry. drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 72428b6..bcabc50 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -1876,7 +1876,11 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, continue; } - if (time_after(jiffies, timeo) && !chip_ready(map, adr)) + /* + * We check "time_after" && "!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)) { -- 2.7.4