[bug report] spi: spi-mem: Extend the SPI mem interface to set a custom memory name

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

 



Hello Frieder Schrempf,

The patch 5d27a9c8ea9e: "spi: spi-mem: Extend the SPI mem interface
to set a custom memory name" from Aug 2, 2018, leads to the following
static checker warning:

	drivers/spi/spi-mem.c:739 spi_mem_probe()
	warn: passing zero to 'PTR_ERR'

drivers/spi/spi-mem.c
    721 static int spi_mem_probe(struct spi_device *spi)
    722 {
    723 	struct spi_mem_driver *memdrv = to_spi_mem_drv(spi->dev.driver);
    724 	struct spi_controller *ctlr = spi->controller;
    725 	struct spi_mem *mem;
    726 
    727 	mem = devm_kzalloc(&spi->dev, sizeof(*mem), GFP_KERNEL);
    728 	if (!mem)
    729 		return -ENOMEM;
    730 
    731 	mem->spi = spi;
    732 
    733 	if (ctlr->mem_ops && ctlr->mem_ops->get_name)
    734 		mem->name = ctlr->mem_ops->get_name(mem);
    735 	else
    736 		mem->name = dev_name(&spi->dev);
    737 
    738 	if (IS_ERR_OR_NULL(mem->name))
--> 739 		return PTR_ERR(mem->name);
                               ^^^^^^^^^^^^^^^^^^

If mem->name were NULL then we would return PTR_ERR(NULL) which is
success.  I don't think mem->name can actually be NULL, but I'm not
sure.


    740 
    741 	spi_set_drvdata(spi, mem);
    742 
    743 	return memdrv->probe(mem);
    744 }

regards,
dan carpenter



[Index of Archives]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux