From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2A3B3A963D for ; Thu, 30 Apr 2026 20:25:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777580732; cv=none; b=A+Y3r43to/qwIgdBJEbiC5QtO4zRRDVFvqcBaoxgZ7ycGKVnCbtC3PB46pBLLn4eijKz9+1X+kFEnR0olf75NuguEcprFEv9IAw49T4pP3th8bD44etI1of2QFW+IMKVYaLAFLZs68nxFDUL8MMmMYtpARVdHMwsS0Vwc1BHZtM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777580732; c=relaxed/simple; bh=rXhUL3CQnj8JY80S2QYzdYw0hx2AT4Yp0bBgbVx7WVc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=bdJSIWcEpH84CEEYJuWswNZjnjcFri+Fa2KDcMxcOLhTGmJv4x8gEdZoRoiUXvHv7ZwUV5H3XX382qRYfcJLMMhLUXxeMLgmHq5chL/jXv6kb9kFlvt/acdCi63gydYbX4B+TLWmPJ4sP+ODHtxvMRTyHMQVbN6Jybpl7z0EG4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Ajiqw0XQ; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Ajiqw0XQ" Message-ID: <510d048c-288e-469b-9d64-720aeab36398@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777580718; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wY/4TfjCrZ1Y4po4PH+NxY7Ja4ymh/2kdaR4Blxsuoo=; b=Ajiqw0XQFwN9METSvN9m3EblbfHZ608vemAoaBmk9HClew+6osZIOhc08/28s89zp4aO3X 7KJ1BwimLJLPWYPm/4Cxd0iMFVAWFnamsp++1sKRVn8vksX/GogJZtTPSvloLGsVz79/jc mYMGsvf+ThXZg8A1EJyVNCrN7SLamTE= Date: Thu, 30 Apr 2026 22:01:13 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] soundwire: stream: sdw_stream_remove_slave(): Check stream is valid To: Richard Fitzgerald , vkoul@kernel.org, yung-chuan.liao@linux.intel.com Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, patches@opensource.cirrus.com References: <20260430143353.2702714-1-rf@opensource.cirrus.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Pierre-Louis Bossart In-Reply-To: <20260430143353.2702714-1-rf@opensource.cirrus.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 4/30/26 16:33, Richard Fitzgerald wrote: > In sdw_stream_remove_slave() check that stream is a valid pointer > before passing it to functions that dereference it. Return 0 if the > pointer is invalid. > > This is a convenience for callers. They can safely call this function > during cleanup code without needing a pointer validity check duplicated > at every call point. > > Signed-off-by: Richard Fitzgerald LGTM Reviewed-by: Pierre-Louis Bossart > --- > drivers/soundwire/stream.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c > index 4ed8fb7663ad..c1ef177a0021 100644 > --- a/drivers/soundwire/stream.c > +++ b/drivers/soundwire/stream.c > @@ -2229,11 +2229,15 @@ EXPORT_SYMBOL(sdw_stream_add_slave); > * @slave: SDW Slave instance > * @stream: SoundWire stream > * > - * This removes and frees port_rt and slave_rt from a stream > + * This removes and frees port_rt and slave_rt from a stream. > + * If stream is NULL or an ERR_PTR, do nothing and return 0. > */ > int sdw_stream_remove_slave(struct sdw_slave *slave, > struct sdw_stream_runtime *stream) > { > + if (IS_ERR_OR_NULL(stream)) > + return 0; > + > mutex_lock(&slave->bus->bus_lock); > > sdw_slave_port_free(slave, stream);