From patchwork Sat May 3 22:19:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4106891 Return-Path: X-Original-To: patchwork-linux-mmc@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 7C3F99F3A0 for ; Sat, 3 May 2014 22:19:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B746420256 for ; Sat, 3 May 2014 22:19:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C99CD20259 for ; Sat, 3 May 2014 22:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753275AbaECWT3 (ORCPT ); Sat, 3 May 2014 18:19:29 -0400 Received: from mail-lb0-f182.google.com ([209.85.217.182]:46169 "EHLO mail-lb0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753050AbaECWT2 (ORCPT ); Sat, 3 May 2014 18:19:28 -0400 Received: by mail-lb0-f182.google.com with SMTP id q8so1827905lbi.27 for ; Sat, 03 May 2014 15:19:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:subject:from:organization:date:mime-version :content-type:content-transfer-encoding:message-id; bh=T/U0s54KCSjfj0Sb0yZUJAzQglNCHNJwjn3uTq8PADA=; b=WmbVBjm85Y92Ajvg4FelZKv6pdJITvunvRqJOl5dyeiNCPTlDgmnfHmZJn1enQO5UQ hJRvkoU7rMYu1NsYRCdsEm2mXdrJl0iA0Gxde5PdBZCXvVCLscQYUEgGNAEaHFXc8Gy4 vSFSK8TdNeZwm568ZrfZeBmVygnMnT+YJCizxLwE+uZqRd/cuO2gBoac/9NOAoRrd7j/ DOMSNvp2DYJaHTOvCk2tOE79RrP7+bu8jsoyIv//A8qKsdMc24QNaqNm8DKRu/lueE8E mIG4jwcBWsOj+ETXO2LoFCDV9/qPMB6rJWFlSS64hlQzZX5nLpfBOGoJzhOt9PJOpVhv zjVw== X-Gm-Message-State: ALoCoQmCmvDr2+oleWGqeYmMrGACodQgp40zQZHVcY3/ZZoKcM8joM56hjkqqueexkG09W7uM+t3 X-Received: by 10.112.12.103 with SMTP id x7mr8539721lbb.36.1399155566581; Sat, 03 May 2014 15:19:26 -0700 (PDT) Received: from wasted.cogentembedded.com (ppp85-140-143-138.pppoe.mtu-net.ru. [85.140.143.138]) by mx.google.com with ESMTPSA id k2sm3797743lbm.23.2014.05.03.15.19.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sat, 03 May 2014 15:19:25 -0700 (PDT) To: linux-mmc@vger.kernel.org, ian@mnementh.co.uk, linux-sh@vger.kernel.org, chris@printf.net, ulf.hansson@linaro.org Subject: [PATCH] tmio_mmc_pio: prevent endless loop in tmio_mmc_set_clock() From: Sergei Shtylyov Organization: Cogent Embedded Date: Sun, 4 May 2014 02:19:29 +0400 MIME-Version: 1.0 Message-Id: <201405040219.30018.sergei.shtylyov@cogentembedded.com> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 I've spent a couple of days with the driver just hanging due to me forgetting to specify the external crystal frequency, so that clk_get_rate() returned 0 and thus the loop in tmio_mmc_set_clock() never ended. I don't think that's an acceptable behavior, so I suggest that the minimum frequency is checked for 0 in tmio_mmc_host_probe(). Signed-off-by: Sergei Shtylyov --- The patch is against Chris Ball's 'mmc.git' repo's 'master' branch. drivers/mmc/host/tmio_mmc_pio.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: mmc/drivers/mmc/host/tmio_mmc_pio.c =================================================================== --- mmc.orig/drivers/mmc/host/tmio_mmc_pio.c +++ mmc/drivers/mmc/host/tmio_mmc_pio.c @@ -1044,6 +1044,15 @@ int tmio_mmc_host_probe(struct tmio_mmc_ } /* + * Check the sanity of mmc->f_min to prevent tmio_mmc_set_clock() from + * looping forever... + */ + if (mmc->f_min == 0) { + ret = -EINVAL; + goto pm_disable; + } + + /* * There are 4 different scenarios for the card detection: * 1) an external gpio irq handles the cd (best for power savings) * 2) internal sdhi irq handles the cd