Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/imagination: Ensure struct pvr_device->power is initialized

When pvr_power_domains_init() handles <=1 power domains, the content of
struct pvr_device->power was previously left uninitialized.

Fixes: e19cc5ab347e3 ("drm/imagination: Use dev_pm_domain_attach_list()")
Reviewed-by: Alessio Belle <alessio.belle@imgtec.com>
Link: https://patch.msgid.link/20260227-single-domain-power-fixes-v1-3-d37ba0825f7c@imgtec.com
Signed-off-by: Matt Coster <matt.coster@imgtec.com>

+29 -15
+29 -15
drivers/gpu/drm/imagination/pvr_power.c
··· 598 598 struct drm_device *drm_dev = from_pvr_device(pvr_dev); 599 599 struct device *dev = drm_dev->dev; 600 600 601 - struct device_link **domain_links __free(kfree) = NULL; 602 601 struct dev_pm_domain_list *domains = NULL; 602 + struct device_link **domain_links = NULL; 603 603 int domain_count; 604 604 int link_count; 605 605 ··· 608 608 609 609 domain_count = of_count_phandle_with_args(dev->of_node, "power-domains", 610 610 "#power-domain-cells"); 611 - if (domain_count < 0) 612 - return domain_count; 611 + if (domain_count < 0) { 612 + err = domain_count; 613 + goto out; 614 + } 613 615 614 - if (domain_count <= 1) 615 - return 0; 616 + if (domain_count <= 1) { 617 + err = 0; 618 + goto out; 619 + } 616 620 617 621 if (domain_count > ARRAY_SIZE(ROGUE_PD_NAMES)) { 618 622 drm_err(drm_dev, "%s() only supports %zu domains on Rogue", 619 623 __func__, ARRAY_SIZE(ROGUE_PD_NAMES)); 620 - return -EOPNOTSUPP; 624 + err = -EOPNOTSUPP; 625 + goto out; 621 626 } 622 627 623 628 link_count = domain_count - 1; 624 629 625 630 domain_links = kzalloc_objs(*domain_links, link_count); 626 - if (!domain_links) 627 - return -ENOMEM; 631 + if (!domain_links) { 632 + err = -ENOMEM; 633 + goto out; 634 + } 628 635 629 636 const struct dev_pm_domain_attach_data pd_attach_data = { 630 637 .pd_names = ROGUE_PD_NAMES, ··· 641 634 642 635 err = dev_pm_domain_attach_list(dev, &pd_attach_data, &domains); 643 636 if (err < 0) 644 - return err; 637 + goto err_free_links; 645 638 646 639 for (i = 0; i < link_count; i++) { 647 640 struct device_link *link; ··· 657 650 domain_links[i] = link; 658 651 } 659 652 660 - pvr_dev->power = (struct pvr_device_power){ 661 - .domains = domains, 662 - .domain_links = no_free_ptr(domain_links), 663 - }; 664 - 665 - return 0; 653 + err = 0; 654 + goto out; 666 655 667 656 err_unlink: 668 657 while (--i >= 0) 669 658 device_link_del(domain_links[i]); 670 659 671 660 dev_pm_domain_detach_list(domains); 661 + domains = NULL; 662 + 663 + err_free_links: 664 + kfree(domain_links); 665 + domain_links = NULL; 666 + 667 + out: 668 + pvr_dev->power = (struct pvr_device_power){ 669 + .domains = domains, 670 + .domain_links = domain_links, 671 + }; 672 672 673 673 return err; 674 674 }