Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp705096pxb; Tue, 5 Apr 2022 19:34:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF2IIjbr20px6/WlMQAA7scRe6VjGJc2oDBSOKeRpE3Nn0QP6WK0to7CJhydMKBoODo4Wf X-Received: by 2002:a05:6a00:174f:b0:4fd:aed5:b5e4 with SMTP id j15-20020a056a00174f00b004fdaed5b5e4mr6627701pfc.39.1649212373430; Tue, 05 Apr 2022 19:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649212373; cv=none; d=google.com; s=arc-20160816; b=k0L6XjttBXX3vvNtGzLgk8sCmGciux89KdgszjsweeU4nlYqWJh156IRpAhxea/Pbz T1DL7Vo0xlugrq0F3jrButk5UyygP/5dsf8Hl1bBVeWCEgDfh+KXSVZlZFlKWj03saPx 0TM14agXUXClMXt0WdT6rZwUbYXmG4hjt30AEIlzyWR+eMgseFKQKG34xmkCgL2E/VHv t0XahTAeBVGmycj+IUGhDK4Eo2klBjgon0HUBsPi9vaipVIX2pmRTAl1gkdmlTeJ8UeF siC4lSOiVviRrMw4skIIXpK2R7K7YjLf4B5yIy8yEfCgRwKTLYHfln0d0i9p6IH3GwJ6 Ur9Q== 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=RIaDm6wZM7geU2JVSF1+Yy4r+ncSP0TWHoKdfyGfyX8=; b=lruL9zkTpg9O05EE7bJvgkq6xt8Xobfqnxmx9kSWx8t6k3KeL9AVj/kMqs5AJDouO1 cCes24V968WUJrU+qW8YpdxenfRABKAMbV7FuumZz96pMKobBH9elr9G8gYhY4N9XzAe S30h4vBPgxJ6R+IPgsFZJc/yXQY2ljqbEmMNX2MuMkivGzwNdIsZ5sMFARW4WIj7bu1H lf5yQfSLYqGMnJE2Whg7KbvkS3faEdtFZ6rK8H7uLT+7vXVpq5ISaRmyh8GmZP8x8Vns ZwnvFba/tgHrIBFNEN69tCmNrJINtdI8lMhSGIrwU79fOhPynD1VF5FGb2GUxBrlA//Z +fQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jxOtjWoi; 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 g11-20020a656ccb000000b003993a4f29e4si5780338pgw.755.2022.04.05.19.32.39; Tue, 05 Apr 2022 19:32:53 -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=jxOtjWoi; 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 S1380154AbiDEN3z (ORCPT + 99 others); Tue, 5 Apr 2022 09:29:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345314AbiDEJWZ (ORCPT ); Tue, 5 Apr 2022 05:22:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A43C43389; Tue, 5 Apr 2022 02:10:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 9070C614FC; Tue, 5 Apr 2022 09:10:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9930AC385A0; Tue, 5 Apr 2022 09:10:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149824; bh=jpH1FFqHwA9Rcvx435BbU8+Ijry2x5lxT/g9E4on9Sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jxOtjWoivyK8oriC7ruazGHIU1QBCQCm7ioTEnR6Oarh9vt5UhRp90055mJLIriWk oj9ofKr2fbaZWHXU4s0JvNHWcAauNt+S4ToefpoEq5dSK4VcLop82LbPXYv/Rc63Fo I9tc5exSNNl2JUl/xENIWoMS7IHOkF8Kls4cUEIg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ulf Hansson , Sasha Levin Subject: [PATCH 5.16 0854/1017] mmc: host: Return an error when ->enable_sdio_irq() ops is missing Date: Tue, 5 Apr 2022 09:29:27 +0200 Message-Id: <20220405070419.586137766@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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.1 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 cf140f4ec864..d739e2b631fe 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -588,6 +588,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 @@ -600,8 +610,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