[bug report] mmc: Add mmc driver for Sunplus SP7021

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

 



Hello Tony Huang,

The patch 4e268fed8b18: "mmc: Add mmc driver for Sunplus SP7021" from
Nov 21, 2022, leads to the following Smatch static checker warning
(linux-next):

	drivers/mmc/host/sunplus-mmc.c:901 spmmc_drv_probe()
	warn: missing unwind goto?

drivers/mmc/host/sunplus-mmc.c
    859 static int spmmc_drv_probe(struct platform_device *pdev)
    860 {
    861         struct mmc_host *mmc;
    862         struct resource *res;
    863         struct spmmc_host *host;
    864         int ret = 0;
    865 
    866         mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
    867         if (!mmc) {
    868                 ret = -ENOMEM;
    869                 goto probe_free_host;

This would be better as "return -ENOMEM;" but this goto is a no-op.

    870         }
    871 
    872         host = mmc_priv(mmc);
    873         host->mmc = mmc;
    874         host->dmapio_mode = SPMMC_DMA_MODE;
    875         host->dma_int_threshold = 1024;
    876 
    877         host->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
    878         if (IS_ERR(host->base))
    879                 return PTR_ERR(host->base);

On the other hand, these should be "goto probe_free_host;"

    880 
    881         host->clk = devm_clk_get(&pdev->dev, NULL);
    882         if (IS_ERR(host->clk))
    883                 return dev_err_probe(&pdev->dev, PTR_ERR(host->clk), "clk get fail\n");

goto

    884 
    885         host->rstc = devm_reset_control_get_exclusive(&pdev->dev, NULL);
    886         if (IS_ERR(host->rstc))
    887                 return dev_err_probe(&pdev->dev, PTR_ERR(host->rstc), "rst get fail\n");

goto

    888 
    889         host->irq = platform_get_irq(pdev, 0);
    890         if (host->irq <= 0)
    891                 return host->irq;

This should be < 0.  Otherwise if we are handling impossible situations
we start debating whether to set the error code in the impossible case?
goto

    892 
    893         ret = devm_request_threaded_irq(&pdev->dev, host->irq,
    894                                         spmmc_irq, spmmc_func_finish_req, IRQF_SHARED,
    895                         NULL, host);
    896         if (ret)
    897                 return ret;

goto

    898 
    899         ret = clk_prepare_enable(host->clk);
    900         if (ret)
--> 901                 return dev_err_probe(&pdev->dev, ret, "failed to enable clk\n");

goto

    902 
    903         ret = mmc_of_parse(mmc);
    904         if (ret)
    905                 goto clk_disable;

Good!

    906 
    907         mmc->ops = &spmmc_ops;
    908         mmc->f_min = SPMMC_MIN_CLK;
    909         if (mmc->f_max > SPMMC_MAX_CLK)
    910                 mmc->f_max = SPMMC_MAX_CLK;
    911 
    912         ret = mmc_regulator_get_supply(mmc);
    913         if (ret)
    914                 goto clk_disable;
    915 
    916         if (!mmc->ocr_avail)
    917                 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
    918         mmc->max_seg_size = SPMMC_MAX_BLK_COUNT * 512;
    919         mmc->max_segs = SPMMC_MAX_DMA_MEMORY_SECTORS;
    920         mmc->max_req_size = SPMMC_MAX_BLK_COUNT * 512;
    921         mmc->max_blk_size = 512;
    922         mmc->max_blk_count = SPMMC_MAX_BLK_COUNT;
    923 
    924         dev_set_drvdata(&pdev->dev, host);
    925         spmmc_controller_init(host);
    926         spmmc_set_sdmmc_mode(host);
    927         host->tuning_info.enable_tuning = 1;
    928         pm_runtime_set_active(&pdev->dev);
    929         pm_runtime_enable(&pdev->dev);
    930         ret = mmc_add_host(mmc);
    931         if (ret)
    932                 goto pm_disable;
    933 
    934         return 0;
    935 
    936 pm_disable:
    937         pm_runtime_disable(&pdev->dev);
    938 
    939 clk_disable:
    940         clk_disable_unprepare(host->clk);
    941 
    942 probe_free_host:
    943         if (mmc)
    944                 mmc_free_host(mmc);
    945 
    946         return ret;
    947 }

regards,
dan carpenter



[Index of Archives]     [Linux Memonry Technology]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux