Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp996126pxb; Wed, 6 Apr 2022 06:18:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2wSOD1hJJrfcHAJwVec0a6uxCPz25wFZg6UCS/l2C6v4goA+0wpYxQ13Su+WZSsUZFcZA X-Received: by 2002:a05:6638:3c2:b0:321:2ac0:7e7d with SMTP id r2-20020a05663803c200b003212ac07e7dmr4813828jaq.271.1649251106878; Wed, 06 Apr 2022 06:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649251106; cv=none; d=google.com; s=arc-20160816; b=atzvV9+7/cOY2GsbzLIeALXfAlGPgnlqDDYJBVuh4s409bLG8+ZOwuTCDKf/OvGfh5 fqwrohlkAFa5GH82j04GjKlx5yUFTxBi8Xu4GyJ2WOLQlHTwdexXBw0qPpQmB+EzrIIt DoZ4pXeTqBs3ExfHUwGC9HcmQBZhpsegWRlxAA0EBxABo5eVuRoAHf2X6kLp8Vqk4XAG XXo7qOAjCI/CHgVzwaab5MKIJyrCWD1dxU5ywVYJdmBW9J5KBZcwSnObnMTBEDST3PCz XWxdAH0VKUyiF4DeogYZ8XG1sUemPbIokhQ4TEyK+HhQXTduavSFQ6H6DEyBqW5J3F3D EiRA== 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=L9Xtm3oaopbNbntIJvbDqCcM5+4B2l5NXi6vXjdHnzo=; b=xhIyvDpVpAiejYWPDCW3cYC/oRyF73SsbEQA09GdKFVfBovfg6iK4DAK9B9aI3WAvE xGHz8r1x5yZlbBLJoEK3purJ6xC3JTfLs22/NP57e4vhElbiF19tB0gJXt3dpUkMmeds XOLp//MoLVVhmseGwvHWM36KL3x/PYCBRgNpt8BMaVEZS5b+eYGcDhEMV3/71UA/NquX 20Olyb8c6aY1EAvwDiI9TjNXHYiPKdBQttwJWy14X7ETyyMu3JGWIn7CPRo9PzsGrU3O yqY19sTzFrKLYbM9i57E7WrPniaCbSBMmgREz+7Fpx619zCBRjnrkXBiIcNuOkseObRc aYSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ccV/n7od"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q15-20020a056e0220ef00b002c7c7bfb698si10096035ilv.54.2022.04.06.06.18.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 06:18:26 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ccV/n7od"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A12896BE944; Wed, 6 Apr 2022 03:55:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1582760AbiDEXth (ORCPT + 99 others); Tue, 5 Apr 2022 19:49:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244638AbiDEKjC (ORCPT ); Tue, 5 Apr 2022 06:39:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F94A8D688; Tue, 5 Apr 2022 03:24:03 -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 B2D1F617CC; Tue, 5 Apr 2022 10:24:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBB61C385A0; Tue, 5 Apr 2022 10:24:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649154242; bh=+VcnWK6RdiXDGyC+txKRR/jNyYOqSekq6T4uv9dDmug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ccV/n7odNQrPRnh9h/c4p71KfrMifVC3oL8/2GSiTLzsLipdA5kGpa8EGGKRWYX1R kbXnVHtk0t5eD61lszw8nAKAATjxZk/GIsGTdZACnR9IM799hez+1IvUIck6RGaxjq mqQaVd73mtzWlPW8jYQg99hN/Il8IDBAOM2Wltf8= 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.10 509/599] mmc: host: Return an error when ->enable_sdio_irq() ops is missing Date: Tue, 5 Apr 2022 09:33:23 +0200 Message-Id: <20220405070313.977342235@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070258.802373272@linuxfoundation.org> References: <20220405070258.802373272@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 864c8c205ff7..03e2f965a96a 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -513,6 +513,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 @@ -525,8 +535,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