Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2166543pxb; Wed, 30 Mar 2022 18:13:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVVaM6ldbOV2vIqo06nbOyvwbHkY6UuvR2aJ30BBYTxM4saRcc8vFmOvu0ORRIFSs7Zt6Q X-Received: by 2002:a05:6402:4396:b0:418:d776:14c1 with SMTP id o22-20020a056402439600b00418d77614c1mr14156917edc.127.1648689198052; Wed, 30 Mar 2022 18:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648689198; cv=none; d=google.com; s=arc-20160816; b=FNBrGgduhq5ja+TegwMMocqXGKSBwt9DRHboa/U45wV0JvgfJ1tgVDKCY+OgDf1phN fLpRjV7TzW94DRRBvcuvVhfcF6kExCoSaiibNy2f1xoV/8w7dn//30SNE5a2TWd+uvx7 R+a/5urRIbJNYPnuebqj1+xPrtApSIk7gmtFnEeZYekfS1UJ3Pn9hRN+a+sQ8qaKb+nE JONWqUxQb8osirQ6X6XsKTGRQKgogRmXnKt0wdNYRZIpS/OduvY5xhOW2sJxsjgrPe9c +69//wVFUV+xM9RZj1L9MtiyYysy7PCM+bNzL95Xo3kLesXQoktureJKdAiXtGu8WiTn YdcQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RIaDm6wZM7geU2JVSF1+Yy4r+ncSP0TWHoKdfyGfyX8=; b=PgteuVNGFAZVIsiGyXAkF8/YrBqRRgKRQyT8tRwCLwMppN74jzXrJ0gGaHhr1twzz3 uHsbBuMWESP/DJYKzhYCgITmOd61G2EvpHEG3lbEz+9JjJ9cOjJVRmxLG6KmotBz/P7r eACTh9bOvGgkxn+Sc5DeX8xlFhkdVx4zL5cqB7Hh+zDvqEcdb/beqLjJLeBlZ4YiZA/c MehtUULVLQg3KiplnfpPfWl1QDWAwPuITWHRKJef584WMwNmJecj6V+SfqiFiB/XIVp5 ANDMGfZq+MyeUVksKHKRiDjahZBJRW3voYQOnTYGYtS7CtuYz3G1ky+kqva03huGnSr7 PQyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=haGhGqyh; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020aa7d708000000b00418c2b5bf73si20485369edq.597.2022.03.30.18.12.51; Wed, 30 Mar 2022 18:13:18 -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=@kernel.org header.s=k20201202 header.b=haGhGqyh; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344601AbiC3MC0 (ORCPT + 99 others); Wed, 30 Mar 2022 08:02:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344919AbiC3Lxq (ORCPT ); Wed, 30 Mar 2022 07:53:46 -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 9E0CA273810; Wed, 30 Mar 2022 04:50:02 -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 48102B81C38; Wed, 30 Mar 2022 11:50:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71B38C340F3; Wed, 30 Mar 2022 11:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648640999; bh=jpH1FFqHwA9Rcvx435BbU8+Ijry2x5lxT/g9E4on9Sg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=haGhGqyhyOu+jd5AX6FjsG4saHD1UQUpxjTjtRuvB/E55dnQHy7I29/9PRkHeJFEu rDLupVqVUfZy3TYmDjb/gZJ3+uPwoYzYuweCZU0jTuV06GWDwPhmWQFSWFhJP/Ha7H IFz3lwm9rP/g/Orm8Ln2sw3Uuz1jqy5HeI5pqliccEi8RMl6/Y1biUookIhKMkr7wb wHxJljVUS6eoB8Y/qEgnlGrHMjrWsD3m8o80BHFmNgw/kJRq0eMz1dBRMDa9teXGDD XJ42yQTKUxUf03BpFSL0BBi1GtiQTgN7sQh1N4I8NvuCwne9x4NJUNW9Gs14Ufnqj7 6ET4cLFU1wKow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ulf Hansson , Sasha Levin , linux-mmc@vger.kernel.org Subject: [PATCH AUTOSEL 5.16 56/59] mmc: host: Return an error when ->enable_sdio_irq() ops is missing Date: Wed, 30 Mar 2022 07:48:28 -0400 Message-Id: <20220330114831.1670235-56-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220330114831.1670235-1-sashal@kernel.org> References: <20220330114831.1670235-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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