diff --git a/src/platform/Linux/MdnsImpl.cpp b/src/platform/Linux/MdnsImpl.cpp index b19e38d1811d98..0aa5001dda1a65 100644 --- a/src/platform/Linux/MdnsImpl.cpp +++ b/src/platform/Linux/MdnsImpl.cpp @@ -512,8 +512,10 @@ CHIP_ERROR MdnsAvahi::PublishService(const MdnsService & service) CHIP_ERROR MdnsAvahi::StopPublish() { CHIP_ERROR error = CHIP_NO_ERROR; - - VerifyOrExit(avahi_entry_group_reset(mGroup) == 0, error = CHIP_ERROR_INTERNAL); + mPublishedServices.clear(); + if (mGroup) { + VerifyOrExit(avahi_entry_group_reset(mGroup) == 0, error = CHIP_ERROR_INTERNAL); + } exit: return error; }