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

ptp: ocp: Make ptp_ocp_unregister_ext() NULL-aware

It's a common practice to make resource release functions be NULL-aware.
Make ptp_ocp_unregister_ext() NULL-aware.

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://patch.msgid.link/20251124084816.205035-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Andy Shevchenko and committed by
Jakub Kicinski
590f5d1f 622cc66e

+10 -14
+10 -14
drivers/ptp/ptp_ocp.c
··· 2225 2225 static void 2226 2226 ptp_ocp_unregister_ext(struct ptp_ocp_ext_src *ext) 2227 2227 { 2228 + if (!ext) 2229 + return; 2230 + 2228 2231 ext->info->enable(ext, ~0, false); 2229 2232 pci_free_irq(ext->bp->pdev, ext->irq_vec, ext); 2230 2233 kfree(ext); ··· 4561 4558 ptp_ocp_detach_sysfs(bp); 4562 4559 ptp_ocp_attr_group_del(bp); 4563 4560 timer_delete_sync(&bp->watchdog); 4564 - if (bp->ts0) 4565 - ptp_ocp_unregister_ext(bp->ts0); 4566 - if (bp->ts1) 4567 - ptp_ocp_unregister_ext(bp->ts1); 4568 - if (bp->ts2) 4569 - ptp_ocp_unregister_ext(bp->ts2); 4570 - if (bp->ts3) 4571 - ptp_ocp_unregister_ext(bp->ts3); 4572 - if (bp->ts4) 4573 - ptp_ocp_unregister_ext(bp->ts4); 4574 - if (bp->pps) 4575 - ptp_ocp_unregister_ext(bp->pps); 4561 + ptp_ocp_unregister_ext(bp->ts0); 4562 + ptp_ocp_unregister_ext(bp->ts1); 4563 + ptp_ocp_unregister_ext(bp->ts2); 4564 + ptp_ocp_unregister_ext(bp->ts3); 4565 + ptp_ocp_unregister_ext(bp->ts4); 4566 + ptp_ocp_unregister_ext(bp->pps); 4576 4567 for (i = 0; i < 4; i++) 4577 - if (bp->signal_out[i]) 4578 - ptp_ocp_unregister_ext(bp->signal_out[i]); 4568 + ptp_ocp_unregister_ext(bp->signal_out[i]); 4579 4569 for (i = 0; i < __PORT_COUNT; i++) 4580 4570 if (bp->port[i].line != -1) 4581 4571 serial8250_unregister_port(bp->port[i].line);