From patchwork Wed Jul 16 08:18:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Srinivas Kandagatla X-Patchwork-Id: 4565061 Return-Path: X-Original-To: patchwork-linux-arm-msm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5B1729F1D6 for ; Wed, 16 Jul 2014 08:19:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8B3902017E for ; Wed, 16 Jul 2014 08:19:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 90D3D201BB for ; Wed, 16 Jul 2014 08:19:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757936AbaGPITI (ORCPT ); Wed, 16 Jul 2014 04:19:08 -0400 Received: from mail-wg0-f50.google.com ([74.125.82.50]:54147 "EHLO mail-wg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751480AbaGPITG (ORCPT ); Wed, 16 Jul 2014 04:19:06 -0400 Received: by mail-wg0-f50.google.com with SMTP id n12so501473wgh.33 for ; Wed, 16 Jul 2014 01:18:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=72tOnrT26N5iJv85yVVPm6Iq6r1pnFOEmIzrFDJRius=; b=FAZQVNPUxLMLBntOOarYFrDxApo9wlEbV8og0aOx9gVxM8ezhZY65+r+VgrheA2GwS qFGEecHzDVrwFUXjXccX2a66dNjPBID1GEgvnRC1rbi0XCmfvSVtrqqRvF+4hRfBhiQf HHN3tB2oZsGWYKSAQne3dDefjr0iQrEOUe3R9l7MF0BfU6auTbpuNjpWWsIO3kTRP4Uw +7GFYuckBqOmdxAFHGEeG914FFkuK9+sYX0ZqEwub13rMsAR5iGIk4KlZD9e1oejVwgn b05Twei2eYfIM5AuTRJ/CceafA+J5Z+kLjouobm/kgMZBaYvwmSQocVANgztwXbqyiIN 0w4w== X-Gm-Message-State: ALoCoQneScK8Ysj2qC55u40Vq59oU8UuNkJ/oYbykk4ucAwQg2BgG3606GzIQDz6/xvfnpIOVB/m X-Received: by 10.194.23.135 with SMTP id m7mr34055429wjf.2.1405498738538; Wed, 16 Jul 2014 01:18:58 -0700 (PDT) Received: from srini-ThinkPad-X1-Carbon-2nd.dlink.com (host-2-99-226-247.as13285.net. [2.99.226.247]) by mx.google.com with ESMTPSA id eh10sm6227810wic.0.2014.07.16.01.18.57 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Jul 2014 01:18:57 -0700 (PDT) From: Srinivas Kandagatla To: Kishon Vijay Abraham I Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-ide@vger.kernel.org, Srinivas Kandagatla Subject: [PATCH] phy: qcom-apq8064: fix possible timeout without check Date: Wed, 16 Jul 2014 09:18:43 +0100 Message-Id: <1405498723-10681-1-git-send-email-srinivas.kandagatla@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch fixes a possible timeout in poll loop without actually checking the register before return. In theory the there is a possibility of loop being scheduled after a long lock/delay, which would then force the loop to exit without actually checking the register. Reported-by: Bartlomiej Zolnierkiewicz Signed-off-by: Srinivas Kandagatla --- Hi Kishon, Just to make it easy for you, am sending this change as a seperate patch so that you can apply it on top of linux-phy next. Thanks, srini drivers/phy/phy-qcom-apq8064-sata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-qcom-apq8064-sata.c b/drivers/phy/phy-qcom-apq8064-sata.c index c9b4dd6..f91e254 100644 --- a/drivers/phy/phy-qcom-apq8064-sata.c +++ b/drivers/phy/phy-qcom-apq8064-sata.c @@ -91,7 +91,7 @@ static int read_poll_timeout(void __iomem *addr, u32 mask) usleep_range(DELAY_INTERVAL_US, DELAY_INTERVAL_US + 50); } while (!time_after(jiffies, timeout)); - return -ETIMEDOUT; + return (readl_relaxed(addr) & mask) ? 0 : -ETIMEDOUT; } static int qcom_apq8064_sata_phy_init(struct phy *generic_phy)