Patch "mmc: host: Return an error when ->enable_sdio_irq() ops is missing" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    mmc: host: Return an error when ->enable_sdio_irq() ops is missing

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     mmc-host-return-an-error-when-enable_sdio_irq-ops-is.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2eb3f437cb30c264e3e5d9746c2a84d5e994462e
Author: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
Date:   Thu Mar 3 17:51:42 2022 +0100

    mmc: host: Return an error when ->enable_sdio_irq() ops is missing
    
    [ 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 <ulf.hansson@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20220303165142.129745-1-ulf.hansson@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

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)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux