Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp596305pxk; Thu, 3 Sep 2020 07:53:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwoWlx14oFrp+MgM3lMcghNK8PxUtfzFD5XQ1n7CbPN2OHU/5KmB0mIDHBEhoGQ9Z0Gxx1f X-Received: by 2002:a05:6402:17ec:: with SMTP id t12mr3379341edy.328.1599144804565; Thu, 03 Sep 2020 07:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599144804; cv=none; d=google.com; s=arc-20160816; b=D4Ec1mCi9WoedRFTu1nT4FQ4bK9DlFIq7ohkwYgUoTm/sAFT8GRrRByr+cg0jVFhDd uYyowWzVu/zbbSD0vgCooRoKIl2X4Ks5dxEFdPeOWlltmntPcPlyzqhKcFPusHNlA3pL 3eyMB5onZnadlsozjMxRmmqq8Zg9Xk/4nuMrZNrR0wzDAfygRpue0Lta1DtAUCbGVf6w fGWsDQpDg8AzBhLRESG4S5qu5kHhOc2boc1QYbrzjkkRtHSXhns1xAVsKclS7P8YSbl3 qxayQ8mfV002dmQpcLCkNpUqgDe+jnXKM8LxbaFpTsVPSs9pkjEhRA9wTpjhu1Rj60fr +YDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=HzFTDgP3uHsyAb7AkkzieUDNo/83flCDa5TCL/+QEv8=; b=CFQBFWJccJOT8+Y7RdhW+aWGoGRPHGIti+6M2aK23b8jBE5RD3MJGHiATZ96V43nVz i/do8hyEFo3KllevBXuPONo60B6387K4YIRZ6KpH6R6LTwZbCJt2ffoExS+GxBXo0nHw LGw5ZmPuT/VYZhIjDoXyzBslNspKZ0MlWIAHfNttQYgx0Rr6m/RSTHgMymSWYZFWdlQ/ jCqFMhMj/ffF/PAQ3Z1vXTS12ao46C+XGEpp+5ABtwTGXeSrhAhem61q+UKG8TOHjlvZ GCDHoxRp+H2Fc0iVPrQoMEf2ASO0YkGOXTUOf+jWua/zZ8emeh3vY/qmeU3dtXOINF/G AF/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YJCkDFUJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y2si1857563edu.414.2020.09.03.07.53.02; Thu, 03 Sep 2020 07:53:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YJCkDFUJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729070AbgICOwT (ORCPT + 99 others); Thu, 3 Sep 2020 10:52:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729115AbgICONd (ORCPT ); Thu, 3 Sep 2020 10:13:33 -0400 Received: from coco.lan (ip5f5ad5c3.dynamic.kabel-deutschland.de [95.90.213.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4E41F20658; Thu, 3 Sep 2020 14:13:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599142412; bh=JYgbbIOnVmePMIhUu47A7uGnn4+Zd9gZZZsHfVycOgE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YJCkDFUJUvutpZBXLk/07WqO2YV/zHF1gkcumsS7eAmPdkyhZE33Hr3pGUxJ1dbkK GRX+ovMcsOrFmDtzGTGfFT1nLG93+yUzGQygX43QAO/HxgIorhSeG81GqB64ELtG5N NABXpLxp8H8NherI6brOGBGo8kEanICIyESU0w8w= Date: Thu, 3 Sep 2020 16:13:28 +0200 From: Mauro Carvalho Chehab To: trix@redhat.com Cc: jasmin@anw.at, o.endriss@gmx.de, rjkm@metzlerbros.de, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] media: dvb-frontends/cxd2099: report errors Message-ID: <20200903161328.62378992@coco.lan> In-Reply-To: <20200722134126.31191-1-trix@redhat.com> References: <20200722134126.31191-1-trix@redhat.com> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Wed, 22 Jul 2020 06:41:26 -0700 trix@redhat.com escreveu: > From: Tom Rix > > Clang static analysis reports this error > > drivers/media/dvb-frontends/cxd2099.c:420:2: warning: Undefined > or garbage value returned to caller > return val; > ^~~~~~~~~~ > > In read_cam_control, the call to read_io can fail. > When it fails val is not set. > > The failure status should be returned to the caller, > not the unset val. > > Similar problem with read_attribute_mem > > Fixes: 0f0b270f905b ("[media] ngene: CXD2099AR Common Interface driver") > > Signed-off-by: Tom Rix > --- > drivers/media/dvb-frontends/cxd2099.c | 14 ++++++++++---- > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/dvb-frontends/cxd2099.c b/drivers/media/dvb-frontends/cxd2099.c > index f88b5355493e..9dfaf18fc4b4 100644 > --- a/drivers/media/dvb-frontends/cxd2099.c > +++ b/drivers/media/dvb-frontends/cxd2099.c > @@ -387,12 +387,15 @@ static int read_attribute_mem(struct dvb_ca_en50221 *ca, > { > struct cxd *ci = ca->data; > u8 val; > + int ret; > > mutex_lock(&ci->lock); > set_mode(ci, 1); > - read_pccard(ci, address, &val, 1); > + ret = read_pccard(ci, address, &val, 1); > + if (!ret) > + ret = val; > mutex_unlock(&ci->lock); > - return val; > + return ret; > } > > static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, > @@ -412,12 +415,15 @@ static int read_cam_control(struct dvb_ca_en50221 *ca, > { > struct cxd *ci = ca->data; > unsigned int val; > + int ret; > > mutex_lock(&ci->lock); > set_mode(ci, 0); > - read_io(ci, address, &val); > + ret = read_io(ci, address, &val); > + if (!ret) > + ret = val; > mutex_unlock(&ci->lock); > - return val; > + return ret; > } > > static int write_cam_control(struct dvb_ca_en50221 *ca, int slot, Hmm... Had you test this one on a real hardware? It is not uncommon to have some DVB devices that would fail reading when the firmware is on cold state. Without testing a patch like that at a real hardware, there's no way to know if this is intentional or if the original developer forgot to add a check for the error. So, at most, it could print some warning message for non-zero return codes. Thanks, Mauro