[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200731083856.GF3703480@smile.fi.intel.com>
Date: Fri, 31 Jul 2020 11:38:56 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Cengiz Can <cengiz@...nel.wtf>
Cc: dan.carpenter@...cle.com, devel@...verdev.osuosl.org,
gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
linux-media@...r.kernel.org, mchehab@...nel.org,
sakari.ailus@...ux.intel.com
Subject: Re: [PATCH v2] staging: atomisp: move null check to earlier point
On Fri, Jul 31, 2020 at 01:17:38AM +0300, Cengiz Can wrote:
> `find_gmin_subdev` function that returns a pointer to `struct
func() are referred with name followed by parentheses.
> gmin_subdev` can return NULL.
> In `gmin_v2p8_ctrl` there's a call to this function but the possibility
> of a NULL was not checked before its being dereferenced. ie:
'. ie:' -> ', i.e.:'
> ```
Instead just shift right by two spaces.
> /* Acquired here --------v */
> struct gmin_subdev *gs = find_gmin_subdev(subdev);
>
> /* v------Dereferenced here */
> if (gs->v2p8_gpio >= 0) {
> ...
> }
> ```
Drop this as per above comment.
> To avoid the issue, null check has been moved to an earlier point
> and return semantics has been changed to reflect this exception.
> Please do note that this change introduces a new return value to
> `gmin_v2p8_ctrl`.
This rather should explain better the semantics change, e.g.
"Now the function() refuses to take NULL argument and returns an error. We also
WARN() for sake of the debugging."
> [NEW] - raise a WARN and return -ENODEV if there are no subdevices.
> - return result of `gpio_request` or `gpio_direction_output`.
> - return 0 if GPIO is ON.
> - return results of `regulator_enable` or `regulator_disable`.
> - according to PMIC type, return result of `axp_regulator_set`
> or `gmin_i2c_write`.
> - return -EINVAL if unknown PMIC type.
This has to go after cutter '---' line below.
> Caught-by: Coverity Static Analyzer CID 1465536
Reported-by:
And as discussed previously,
Suggested-by: Mauro ...
> Signed-off-by: Cengiz Can <cengiz@...nel.wtf>
The code looks good enough (WARN() will probably go away when driver gains
better quality).
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists