From patchwork Sun Sep 14 19:51:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4902301 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A2FBBEEA6 for ; Sun, 14 Sep 2014 20:49:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B553520131 for ; Sun, 14 Sep 2014 20:49:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D00CD201FB for ; Sun, 14 Sep 2014 20:49:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbaINUtI (ORCPT ); Sun, 14 Sep 2014 16:49:08 -0400 Received: from mail-we0-f180.google.com ([74.125.82.180]:57253 "EHLO mail-we0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752799AbaINUtH (ORCPT ); Sun, 14 Sep 2014 16:49:07 -0400 Received: by mail-we0-f180.google.com with SMTP id t60so3078802wes.25 for ; Sun, 14 Sep 2014 13:49:05 -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:organization :user-agent:mime-version:content-transfer-encoding:content-type; bh=DMY9SD7ePhzpL/gokl7wCDkSEdWMwOVl4eLz+GtA5Hs=; b=ZVRgLsF6ZM5Oa6eUV//klXZP+92NERoowJ/npamAL2oY4CjbKqEEbYEHmeJMbYBYQs 0vkvSUTVu92b4F61TmU8Qm7oNMXP/UCeaLb4FmtYT5C22zbGxlf76F1YcBhzyrrmd8em Uavv1/WosUm3KI5rUQ8HjwlLVNusbFr75o5d2SYH693bKOv718ySeAxFALKZX/JTpu0T SPCw8h3o8h2g5B3aFWJpmDGYJf3o/RT0D7XtqbBMYN9AUtCfX3wHPTfj1Zuoy2GNGw6v NQh1ZpIyRTcOlNdyQZhqFqPHitDCkPYHeO+rgW2WcH7a5pYWu9fNK1/S6FH/LjrDqsHN TUCw== X-Gm-Message-State: ALoCoQkRhuc+3GZdMCaC6pR7c/Zal6x8npOv+uNve+3oJdbFrY6DqZ7/kt2c0TORmMglPfIRjKCa X-Received: by 10.194.71.210 with SMTP id x18mr27131822wju.6.1410727745628; Sun, 14 Sep 2014 13:49:05 -0700 (PDT) Received: from wasted.cogentembedded.com (80.178.206.101.adsl.012.net.il. [80.178.206.101]) by mx.google.com with ESMTPSA id k5sm9385836wiv.21.2014.09.14.13.49.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Sep 2014 13:49:04 -0700 (PDT) From: Sergei Shtylyov To: linux-mmc@vger.kernel.org, ian.molton@codethink.co.uk, chris@printf.net, ulf.hansson@linaro.org Cc: linux-sh@vger.kernel.org Subject: [PATCH v3] tmio_mmc_pio: prevent endless loop in tmio_mmc_set_clock() Date: Sun, 14 Sep 2014 23:51:24 +0400 Message-ID: <3179866.4yEKrAKQ30@wasted.cogentembedded.com> Organization: Cogent Embedded Inc. User-Agent: KMail/4.13.3 (Linux/3.15.10-201.fc20.x86_64; KDE/4.13.3; x86_64; ; ) MIME-Version: 1.0 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 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 Cc: stable@vger.kernel.org Acked-by: Ian Molton --- The patch is against Ulf Hansson's 'mmc.git' repo's 'fixes' branch. Changes in version 3: - added Cc: stable. Changes in version 2: - fixed grammar in the changelog. 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