[bug report] irqchip/mbigen: move to use bus_get_dev_root()

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

 



Hello Greg Kroah-Hartman,

The patch fea087fc291b: "irqchip/mbigen: move to use
bus_get_dev_root()" from Mar 13, 2023, leads to the following Smatch
static checker warning:

	drivers/irqchip/irq-mbigen.c:258 mbigen_of_create_domain()
	error: potentially dereferencing uninitialized 'child'.

drivers/irqchip/irq-mbigen.c
    235 static int mbigen_of_create_domain(struct platform_device *pdev,
    236                                    struct mbigen_device *mgn_chip)
    237 {
    238         struct device *parent;
    239         struct platform_device *child;
    240         struct irq_domain *domain;
    241         struct device_node *np;
    242         u32 num_pins;
    243 
    244         for_each_child_of_node(pdev->dev.of_node, np) {
    245                 if (!of_property_read_bool(np, "interrupt-controller"))
    246                         continue;
    247 
    248                 parent = bus_get_dev_root(&platform_bus_type);
    249                 if (parent) {

Smatch is concerned that "parent" can be NULL.  Probably unlikely in
real life.

    250                         child = of_platform_device_create(np, NULL, parent);
    251                         put_device(parent);
    252                         if (!child) {
    253                                 of_node_put(np);
    254                                 return -ENOMEM;
    255                         }
    256                 }
    257 
--> 258                 if (of_property_read_u32(child->dev.of_node, "num-pins",
    259                                          &num_pins) < 0) {
    260                         dev_err(&pdev->dev, "No num-pins property\n");
    261                         of_node_put(np);
    262                         return -EINVAL;
    263                 }
    264 
    265                 domain = platform_msi_create_device_domain(&child->dev, num_pins,
    266                                                            mbigen_write_msg,
    267                                                            &mbigen_domain_ops,
    268                                                            mgn_chip);
    269                 if (!domain) {
    270                         of_node_put(np);
    271                         return -ENOMEM;
    272                 }
    273         }
    274 
    275         return 0;
    276 }

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux