Re: [PATCH] PCI: pnv_php: Use common error handling code in pnv_php_alloc_slot()

Manivannan Sadhasivam <[email protected]> Mon, 22 Jun 2026 17:58:38 +0200
Newsgroups org.kernel.vger.kernel-janitors,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci,org.ozlabs.lists.linuxppc-dev
Message-ID <tlemzejir3wi3rff2x65bbqqknzel4nwy3fnlvruyg7fll4p44@zqrf3z2cxhuu>
On Thu, Jun 11, 2026 at 11:25:12AM +0200, Markus Elfring wrote:
> From: Markus Elfring <[email protected]>
> Date: Thu, 11 Jun 2026 11:16:49 +0200
> 
> Use an additional label so that a bit of exception handling can be better
> reused at the end of an if branch.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <[email protected]>
> ---
>  drivers/pci/hotplug/pnv_php.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
> index ff92a5c301b8..e448f1802002 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -791,16 +791,15 @@ static struct pnv_php_slot *pnv_php_alloc_slot(struct device_node *dn)
>  		return NULL;
>  
>  	php_slot->name = kstrdup(label, GFP_KERNEL);
> -	if (!php_slot->name) {
> -		kfree(php_slot);
> -		return NULL;
> -	}
> +	if (!php_slot->name)
> +		goto free_php_slot;
>  
>  	/* Allocate workqueue for this slot's interrupt handling */
>  	php_slot->wq = alloc_workqueue("pciehp-%s", WQ_PERCPU, 0, php_slot->name);
>  	if (!php_slot->wq) {
>  		SLOT_WARN(php_slot, "Cannot alloc workqueue\n");
>  		kfree(php_slot->name);
> +free_php_slot:

Really? What kind of coding practice is this?

- Mani

-- 
மணிவண்ணன் சதாசிவம்