lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y0snkMEp9WqGtzom@paasikivi.fi.intel.com>
Date:   Sat, 15 Oct 2022 21:35:12 +0000
From:   Sakari Ailus <sakari.ailus@...ux.intel.com>
To:     Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc:     Prabhakar <prabhakar.csengg@...il.com>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Rob Herring <robh+dt@...nel.org>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        Hans Verkuil <hverkuil@...all.nl>,
        Shawn Tu <shawnx.tu@...el.com>,
        Jacopo Mondi <jacopo@...ndi.org>, linux-media@...r.kernel.org,
        devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-renesas-soc@...r.kernel.org,
        Biju Das <biju.das.jz@...renesas.com>,
        Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
Subject: Re: [PATCH v2 4/5] media: i2c: ov5645: Return zero for s_stream(0)

Hi Laurent,

On Sat, Oct 15, 2022 at 09:25:37AM +0300, Laurent Pinchart wrote:
> Hi Prabhakar,
> 
> Thank you for the patch.
> 
> On Fri, Oct 14, 2022 at 07:34:58PM +0100, Prabhakar wrote:
> > From: Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
> > 
> > Always return zero while stopping the stream as the caller will ignore the
> > return value.
> > 
> > This patch drops checking the return value of ov5645_write_reg() and
> > continues further in the code path while stopping stream. The user anyway
> > gets an error message in case ov5645_write_reg() fails.
> 
> Continuing all the way to pm_runtime_put() is fine, but I don't think
> the function should return 0. It's not up to the driver to decide if a
> failure would be useful to signal to the caller or not.

If the function returns an error when disabling streaming, what is the
expected power state of the device after this?

The contract between the caller and the callee is that the state is not
changed if there is an error. This is a special case as very few callers
check the return value for streamoff operation and those that do generally
just print something. I've never seen a caller trying to prevent streaming
off in this case, for instance.

Of course we could document that streaming off always counts as succeeded
(e.g. decreasing device's runtime PM usage_count) while it could return an
informational error code. But I wonder if anyone would ever benefit from
that somehow. :-)

> 
> > Suggested-by: Sakari Ailus <sakari.ailus@...ux.intel.com>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@...renesas.com>
> > ---
> > v1->v2
> > * New patch
> > ---
> >  drivers/media/i2c/ov5645.c | 11 ++++-------
> >  1 file changed, 4 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
> > index a0b9d0c43b78..b3825294aaf1 100644
> > --- a/drivers/media/i2c/ov5645.c
> > +++ b/drivers/media/i2c/ov5645.c
> > @@ -995,14 +995,11 @@ static int ov5645_s_stream(struct v4l2_subdev *subdev, int enable)
> >  		if (ret < 0)
> >  			goto err_rpm_put;
> >  	} else {
> > -		ret = ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x40);
> > -		if (ret < 0)
> > -			return ret;
> > +		ov5645_write_reg(ov5645, OV5645_IO_MIPI_CTRL00, 0x40);
> > +
> > +		ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
> > +				 OV5645_SYSTEM_CTRL0_STOP);
> >  
> > -		ret = ov5645_write_reg(ov5645, OV5645_SYSTEM_CTRL0,
> > -				       OV5645_SYSTEM_CTRL0_STOP);
> > -		if (ret < 0)
> > -			return ret;
> >  		pm_runtime_put(ov5645->dev);
> >  	}
> >  
> 

-- 
Regards,

Sakari Ailus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ