Provided there is no commercial arrangement, I don't think there is any liability. Presumably you are talking about sailing in company with friends? It is still a good idea to agree in a not too heavy-handed way before you set off that everybody is taking part at their own risk. We do this with racing crew. We jokily point out that although we will of course take every care, basically they have volunteered to come with us because they want to, and we will take a dim view if they try to sue us if we drown them. This usually gets a laugh, but it makes the point.
Cruising in company is great for giving extra confidence, especially when undertaking longer crossings etc, because there is a feeling that there is someone there to help should anything go wrong. However, if anything does go wrong (one of the boats goes aground, say, or its mast goes over the side) you must be very careful about not putting other boats into danger trying to rescue them.
Last year when we volunteered via VHF to stand by a boat that was aground on a sandbank during a gale we immediately had the Coastguard on the radio warning us not to do anything silly! But without putting other boats into danger, there is help that can be given: radio relay etc. So the confidence is not misplaced.
And there are other practical benefits from cruising in company: people there to take your warps - and share the celebrations - when you reach the destination. Enjoy!