Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3032856pxb; Mon, 18 Apr 2022 14:01:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5PkUxMNJsX7vo6e8pHgcQHWnE9Uk14CK6OXsKcsziAQpGAQpm9uH9qWqIhjAL8xDOmHBm X-Received: by 2002:a05:6402:438c:b0:423:f57a:596f with SMTP id o12-20020a056402438c00b00423f57a596fmr2955825edc.367.1650315709402; Mon, 18 Apr 2022 14:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650315709; cv=none; d=google.com; s=arc-20160816; b=U7fnnVw2IIXYDNiA65NGYs47dADQ+kPKSdcMcYYaHKoLV9qC5IFcrNSSZAxYAJe4bq 3Yup2HUHADiHuL58ckZPtYcdrlmG6Ej/nSBVQWFS0C5E9QnuVJMPS+5r9Q+lugpVGeFN 0mk/3Xrlx5YrK9J/NCwOy1tvmFaRS4t2Ec2Nbap7Vx5JO57YtTZXWc8g6COM9sQXhBHU 5YX23WPiOhNJfC6F+rbDAmsY4vhYL3ITRRxWS8RAegtu1uZ+OU5fs3uiSmvyPcUO/8WD xrxPEfe7u24zncuFaBJN0jTHNvIUH19kXCBD5vpGMV9AVdXHdeRBKvEOJ6CAhXaS0i/m IsdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZFDX2uVxD46Z/DEm7H3bxU/rdEwki/ivh00atGckkWI=; b=Dt4P4DN9j/Gkb4MWPnOG9CYIWCu4z1ung3ZzoSg8kiittrvrj9wECNSht/s7D285a7 10Nlrh/DEH8+0o5vydikRc+7rPB5VgvXxiLEzCp4ldSjqFQDd8a7h4+BK3TZ3o6HpP8y E6n5B/ck7Tvp5OU1IvYTQ/L+2AdYPxyeAF2r0PsXi986swgleVzjWVqcxyAMtpV/gHtu QOr1d4vgiTa7XmmtlKwsl0VQrjvkqg59i5IMlnKIUPxLyCN9ebMIIognVuArZZuvQXSI v/+XWGbkZsjyjKVWX0pr2wEzxFCc4iQrUfqHwTek0MdD8t+2SRdB4lXoskVUSn93LJeQ dPJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IcjOBfFI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a1709062ec900b006df76385d83si6809502eji.547.2022.04.18.14.01.23; Mon, 18 Apr 2022 14:01:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IcjOBfFI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343817AbiDRNy0 (ORCPT + 99 others); Mon, 18 Apr 2022 09:54:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244855AbiDRNa6 (ORCPT ); Mon, 18 Apr 2022 09:30:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 755691EC73; Mon, 18 Apr 2022 05:56:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 349F1B80E44; Mon, 18 Apr 2022 12:56:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65ACBC385A7; Mon, 18 Apr 2022 12:56:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286574; bh=TjnvLi83cOFFJf6NtahCnNbN2EUZK9664M/61JhVXLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IcjOBfFIzBfvrSIxdmx+CnXUvDanq6IsaKIxEaTtBvgvU2BgIeHZPEEzAOfz5Yafs dVQiOgh0GrVDo37e6MjttfBc09PeSdw2kuAXmKoK7FCt3fcRwgcqzwUdFJO3V4qGTe NBi1EiMVtmnzYEJJd4P6VCUxQfU2qaCsd7AlEyAE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Hansson , Sasha Levin Subject: [PATCH 4.14 179/284] mmc: host: Return an error when ->enable_sdio_irq() ops is missing Date: Mon, 18 Apr 2022 14:12:40 +0200 Message-Id: <20220418121216.828086987@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ulf Hansson [ Upstream commit d6c9219ca1139b74541b2a98cee47a3426d754a9 ] Even if the current WARN() notifies the user that something is severely wrong, we can still end up in a PANIC() when trying to invoke the missing ->enable_sdio_irq() ops. Therefore, let's also return an error code and prevent the host from being added. While at it, move the code into a separate function to prepare for subsequent changes and for further host caps validations. Signed-off-by: Ulf Hansson Link: https://lore.kernel.org/r/20220303165142.129745-1-ulf.hansson@linaro.org Signed-off-by: Sasha Levin --- drivers/mmc/core/host.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 3740fb0052a4..4da2bcfd0649 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -401,6 +401,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) EXPORT_SYMBOL(mmc_alloc_host); +static int mmc_validate_host_caps(struct mmc_host *host) +{ + if (host->caps & MMC_CAP_SDIO_IRQ && !host->ops->enable_sdio_irq) { + dev_warn(host->parent, "missing ->enable_sdio_irq() ops\n"); + return -EINVAL; + } + + return 0; +} + /** * mmc_add_host - initialise host hardware * @host: mmc host @@ -413,8 +423,9 @@ int mmc_add_host(struct mmc_host *host) { int err; - WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) && - !host->ops->enable_sdio_irq); + err = mmc_validate_host_caps(host); + if (err) + return err; err = device_add(&host->class_dev); if (err) -- 2.34.1