From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx1.white.stw.pengutronix.de (mx1.white.stw.pengutronix.de [185.203.200.13]) (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 8A8D13DB326 for ; Fri, 24 Jul 2026 11:57:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.203.200.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784894330; cv=none; b=o9CYklkocpKez8HVI35Yxt9IFSqDLkBTWeOlaToCo+pjrgXGy/7skrGS0VAljxRV9DndjUi596Me8prfTt3/kSbriXzOQJOTbIzgywgu6ehxJWhoQm+Xuo6T8eXgNNn7y+7rPHQ+YcH2T1ZoZpMIP3xiXkT251AUtHx9K1UugNg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784894330; c=relaxed/simple; bh=xAW0y0Xsw6xK0bLA2zXHeJC/Uad5uYkpGJ+aL0pLNi0=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=j8dyuKPLCQw3ZwAoENJel0EyoqbHz0DaWPz0m+zEp3cQL8E/iG8JPOFqmuOD6weJSylRbMeA95Q8FBqlDU3s6mIKlo38AKovjf3jMuhj0BbFTiRs3xehJaFPo8WviiPeksRiUlu9QwfGtwC/Vx4vj01i0feDMx1N7rKmbZtzVcQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de; spf=pass smtp.mailfrom=pengutronix.de; arc=none smtp.client-ip=185.203.200.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pengutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pengutronix.de Received: from drehscheibe.grey.stw.pengutronix.de (drehscheibe.grey.stw.pengutronix.de [IPv6:2a0a:edc0:0:c01:1d::a2]) (Authenticated sender: relay-from-drehscheibe.grey.stw.pengutronix.de) by mx1.white.stw.pengutronix.de (Postfix) with ESMTPSA id 573AD2004F0; Fri, 24 Jul 2026 13:51:24 +0200 (CEST) Received: from lupine.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::4e] helo=lupine) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wnER2-0013Sq-0r; Fri, 24 Jul 2026 13:51:24 +0200 Received: from pza by lupine with local (Exim 4.98.2) (envelope-from ) id 1wnER2-000000008LL-0oDz; Fri, 24 Jul 2026 13:51:24 +0200 Message-ID: <9ae7bf8ebb8a9b297582cbb992240f5f3e078134.camel@pengutronix.de> Subject: Re: [PATCH] reset: sky1: propagate regmap errors and validate signals From: Philipp Zabel To: kr494167@gmail.com Cc: gary.yang@cixtech.com, linux-kernel@vger.kernel.org Date: Fri, 24 Jul 2026 13:51:24 +0200 In-Reply-To: <20260724044210.31592-1-kr494167@gmail.com> References: <20260724044210.31592-1-kr494167@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2-0+deb13u1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fr, 2026-07-24 at 10:12 +0530, kr494167@gmail.com wrote: > From: Surendra Singh Chouhan >=20 > sky1_reset_assert(), sky1_reset_deassert(), sky1_reset(), and > sky1_reset_status() ignored the return values of sky1_reset_set() and > regmap_read(). If regmap operations failed (e.g. due to bus I/O errors), Which bus I/O errors cause error return values? The regmap behind this is MMIO. > error codes were swallowed and functions returned success (0) or incorrec= t > status (1). >=20 > In addition, sky1_src_signals is a sparse array containing unmapped entri= es > (offset =3D=3D 0 && bit =3D=3D 0). This is not true. Please point out the alleged unmapped entries. > Out-of-bounds id lookups or references to > unmapped entries were not validated before performing regmap operations. >=20 > Fix these by capturing and propagating regmap read/write errors across > all ops, and adding bounds and unmapped signal validation in > sky1_reset_set() and sky1_reset_status(). >=20 > Fixes: 7cd3ca90d921 ("reset: add Sky1 soc reset support") > Signed-off-by: Surendra Singh Chouhan > --- > drivers/reset/reset-sky1.c | 54 +++++++++++++++++++++++++++++++------- > 1 file changed, 44 insertions(+), 10 deletions(-) >=20 > diff --git a/drivers/reset/reset-sky1.c b/drivers/reset/reset-sky1.c > index 78e80a533c39..885eb9563ef8 100644 > --- a/drivers/reset/reset-sky1.c > +++ b/drivers/reset/reset-sky1.c > @@ -267,8 +267,17 @@ static int sky1_reset_set(struct reset_controller_de= v *rcdev, > unsigned long id, bool assert) > { > struct sky1_src *sky1src =3D to_sky1_src(rcdev); > - const struct sky1_src_signal *signal =3D &sky1src->signals[id]; > - unsigned int value =3D assert ? 0 : signal->bit; > + const struct sky1_src_signal *signal; > + unsigned int value; > + > + if (id >=3D sky1src->rcdev.nr_resets) > + return -EINVAL; This is unnecessary. The id field of struct reset_control, where this id comes from, is set up after checking exactly this in fwnode_reset_simple_xlate().=20 > + > + signal =3D &sky1src->signals[id]; > + if (!signal->offset && !signal->bit) > + return -EINVAL; This is unnecessary. All array entries should contain a bit value. > + > + value =3D assert ? 0 : signal->bit; > =20 > return regmap_update_bits(sky1src->regmap, > signal->offset, signal->bit, value); >=20 [...] > static int sky1_reset_status(struct reset_controller_dev *rcdev, > unsigned long id) > { > - unsigned int value =3D 0; > struct sky1_src *sky1src =3D to_sky1_src(rcdev); > - const struct sky1_src_signal *signal =3D &sky1src->signals[id]; > + const struct sky1_src_signal *signal; > + unsigned int value =3D 0; > + int ret; > + > + if (id >=3D sky1src->rcdev.nr_resets) > + return -EINVAL; > + > + signal =3D &sky1src->signals[id]; > + if (!signal->offset && !signal->bit) > + return -EINVAL; Both unnecessary, see above. > + > + ret =3D regmap_read(sky1src->regmap, signal->offset, &value); > + if (ret) > + return ret; > =20 > - regmap_read(sky1src->regmap, signal->offset, &value); > return !(value & signal->bit); > } > =20 regards Philipp