From patchwork Thu Sep 18 19:33:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 4933871 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 5BE7F9F2EC for ; Thu, 18 Sep 2014 20:32:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 607992015D for ; Thu, 18 Sep 2014 20:33:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C5CB20166 for ; Thu, 18 Sep 2014 20:33:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756824AbaIRUc7 (ORCPT ); Thu, 18 Sep 2014 16:32:59 -0400 Received: from mail-we0-f170.google.com ([74.125.82.170]:44989 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756755AbaIRUc7 (ORCPT ); Thu, 18 Sep 2014 16:32:59 -0400 Received: by mail-we0-f170.google.com with SMTP id u57so1526082wes.15 for ; Thu, 18 Sep 2014 13:32:58 -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=01O44vNUcpScIf930C5VlKYrmlJSAD8DfxM96x+8ztM=; b=K4/BQGshyuJ7cBzJbQQ1OUfgaGs6Mg02aE3sVCGY/vKgWnrf8elqaIq/lt+tDJIFc9 O7i9X4EOOadOudbA8RBkFUL2+Y2QCGgbWGv3L9Cjz4A6KHJraa5jA2rJ1jSOl108fjQ/ b9nrQlPARh/3eZczwTLmql71+XjsffNDDZE7GN2xLhhh9FmKe57IlTWuMhb8iS7JR61b kV6SWCq3ztWZIUZ2GAHPZFhSOEHt4cDd5CBSzWLYxrgr3HBCQsde2VcV6hzspb1QhMwv JdJZMdlL9TGFq4M2k9GwmqT2UZaOSVonK5K86IaROqbat1mdEEDnvpVjwA+mT744jYK0 Kh+A== X-Gm-Message-State: ALoCoQmbFxG1ZxPsrwdSMaEQCGdyxhivwzPrqv4qmI9z/cWgY6l5rvbz1gq0LfdX/kSF9eEgj3Ic X-Received: by 10.194.8.168 with SMTP id s8mr5595849wja.129.1411072377946; Thu, 18 Sep 2014 13:32:57 -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 pm6sm27296453wjb.36.2014.09.18.13.32.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Sep 2014 13:32:56 -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 v4] tmio_mmc_pio: prevent endless loop in tmio_mmc_set_clock() Date: Thu, 18 Sep 2014 23:33:49 +0400 Message-ID: <10228473.uOqbQ0oioV@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=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 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 Acked-by: Ian Molton Cc: stable@vger.kernel.org --- The patch is against Ulf Hansson's 'mmc.git' repo's 'next' branch. Changes in version 4: - rebased to the 'next' branch, resolving reject; - added Ian Molton's ACK. 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 @@ -1091,6 +1091,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 host_free; + } + + /* * While using internal tmio hardware logic for card detection, we need * to ensure it stays powered for it to work. */