From: Fedor Pchelkin <pchelkin@ispras.ru>
To: Roman Smirnov <r.smirnov@omp.ru>
Cc: Michael Krufky <mkrufky@linuxtv.org>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Jia-Ju Bai <baijiaju1990@gmail.com>,
Hans Verkuil <hverkuil-cisco@xs4all.nl>,
lvc-project@linuxtesting.org, Sergey Shtylyov <s.shtylyov@omp.ru>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [lvc-project] [PATCH 1/3] media: tuners: tda18271: fix error code handling in tda18271_attach()
Date: Wed, 24 Apr 2024 23:20:31 +0300 [thread overview]
Message-ID: <20240424202031.syigrtrtipbq5f2l@fpc> (raw)
In-Reply-To: <20240424180650.tpemkolglnkb2pyn@fpc>
On Wed, 24. Apr 21:06, Fedor Pchelkin wrote:
> Hello Roman,
>
> On Tue, 16. Apr 14:45, Roman Smirnov wrote:
> > tda18271_attach() uses the hybrid_tuner_request_state() macro.
> > It may return the error code -ENOMEM, but the function handle
> > the value 0 instead.
>
> Maybe hybrid_tuner_request_state macro declaration should be fixed to
> generate zero in case of a memory allocation failure?
>
> At least it has a comment stating the following
> * 0 - no instances, indicates an error - kzalloc must have failed
>
> And supposedly a number of drivers implemented the error handling based on
> this assumption.
>
> The drivers mentioned in this series are not the only ones susceptible to
> the problem. Grepping through "hybrid_tuner_request_state" calls also gives
> out tda9887, xc2028, r820t and others.
>
> >
> > Found by Linux Verification Center (linuxtesting.org) with Svace.
> >
> > Fixes: b9302fa7ed97 ("media: tuners: fix error return code of hybrid_tuner_request_state()")
Looking more thoroughly, I think commit b9302fa7ed97 ("media: tuners: fix
error return code of hybrid_tuner_request_state()") should be reverted
because it just contradicts with the return values contract which is stated
in the comment for the macro and which is followed by all the existing
drivers.
__ret should be assigned 0 in error case as was before the commit.
> > Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
> > ---
> > drivers/media/tuners/tda18271-fe.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/tuners/tda18271-fe.c b/drivers/media/tuners/tda18271-fe.c
> > index a7e721baaa99..23432210f06a 100644
> > --- a/drivers/media/tuners/tda18271-fe.c
> > +++ b/drivers/media/tuners/tda18271-fe.c
> > @@ -1255,7 +1255,7 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
> > hybrid_tuner_instance_list,
> > i2c, addr, "tda18271");
> > switch (instance) {
> > - case 0:
> > + case -ENOMEM:
> > goto fail;
> > case 1:
> > /* new tuner instance */
> > --
> > 2.34.1
> >
prev parent reply other threads:[~2024-04-24 20:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-16 11:45 [PATCH 1/3] media: tuners: tda18271: fix error code handling in tda18271_attach() Roman Smirnov
2024-04-16 11:45 ` [PATCH 2/3] media: tuners: xc5000: fix error code handling in xc5000_attach() Roman Smirnov
2024-04-16 18:58 ` Sergey Shtylyov
2024-04-16 11:45 ` [PATCH 3/3] media: tuners: tuner_simple: fix error code handling in simple_tuner_attach() Roman Smirnov
2024-04-16 18:31 ` Sergey Shtylyov
2024-04-16 18:32 ` [PATCH 1/3] media: tuners: tda18271: fix error code handling in tda18271_attach() Sergey Shtylyov
2024-04-24 18:06 ` [lvc-project] " Fedor Pchelkin
2024-04-24 20:20 ` Fedor Pchelkin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240424202031.syigrtrtipbq5f2l@fpc \
--to=pchelkin@ispras.ru \
--cc=baijiaju1990@gmail.com \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=mchehab@kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=r.smirnov@omp.ru \
--cc=s.shtylyov@omp.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox