On Mon, Feb 15, 2021 at 04:57:57PM +0300, Dan Carpenter wrote:
> > d715ff8acbd587 Guoqing Jiang 2020-10-23 1800 /*
> > d715ff8acbd587 Guoqing Jiang 2020-10-23 1801 * "refcount ==
0" happens if a previous thread calls get_or_create_srv
> > d715ff8acbd587 Guoqing Jiang 2020-10-23 1802 * allocate srv, but
chunks of srv are not allocated yet.
> > d715ff8acbd587 Guoqing Jiang 2020-10-23 1803 */
> > f0751419d3a15f Md Haris Iqbal 2021-02-12 1804 if (IS_ERR(srv) ||
refcount_read(&srv->refcount) == 0) {
> > f0751419d3a15f Md Haris Iqbal 2021-02-12 @1805 err =
PTR_ERR(srv);
> >
> > It's not 100% clear to me that an error code is required when
> > refcount_read() is zero. Maybe "err = 0;" is okay in that
situation?
> I don't see how srv can be zero
The cross function database was probably out of date.
Regardless of if it is up to date or not, this sequence:
if (refcount_read(&srv->refcount) == 0)
err = PTR_ERR(srv);
Is completely bogus
eg prove srv is a valid pointer by de-refing and then passing a valid
pointer to PTR_ERR
Jason