Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp589787pxk; Thu, 3 Sep 2020 07:43:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjK9FmuAdbD3y96X6SwMd/cMJ/1/J36GWj+eXJCM1hIu9FwivuG7y/Fdpu2RgTyhhpN0qC X-Received: by 2002:a17:906:7cb:: with SMTP id m11mr2562494ejc.41.1599144219636; Thu, 03 Sep 2020 07:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599144219; cv=none; d=google.com; s=arc-20160816; b=osb6WJs6OVdd3wflJCNkn27BO/QO4hDK+EsK0/KCkCe99aHIeIEaHiIkYM8P000H7j SkZS2AXqWiR2j3//En4DuUQnaenn/GJbGdwjGJB3Od5MEnjU1jyLl7IzV+q6khKimDDC R//vUtXcQx8bZpfQCu2ckDwc1m+DQOu196MLzomyDr2Ra5tgfKG0URflZGE8rnrm3kFn E2wD9zCb1U9v6lJA5Ya56ctk1kB10Tl2C+fF6kOs1rxpjzbKkDEWmS+fjbW34ehQ31KU PAsZXrERq14ZfHsensf86aRLLA7PjBT/hBKHlg+BUVM5HtFnfH6o7d2HRjdoC34mE2Zi wYsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=dlXSpmpAiY7YS5kYtaeWA3wo80DV7Gum6Jwj3vtpgjg=; b=whCWsRWfbjR7H1d+9sFkazqwk5cBi3W503k1EZlDFmjkH5Qpncetn9dAzSimq4/9/X HQbcE1qHuqRvCnEWC8GBQzedHTfzNEgSfFv4swyQNJiazsst6vliLbDoYwFxPsBFkyBQ 9ouP6HB8BNPS3kfRAmgTvCYitdh3P6H+LvEqqqsGUN4n9Lsl8r6NcaXwxffhsIjgQe1p ZSbvy2kOpqjgiC39M+qliLr9ArRFaE2v0Zt+TAxAC6ZjnFzj8EYmxzClXGXin6MVFI1w 2gqRgTzzvvvxNcyojFv2scFccur9+nidVUViFZDhM5ctqGJYtTBDqcS/CKQVgNebyoUV AjPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Tb4u650/"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si1992911ejd.95.2020.09.03.07.43.15; Thu, 03 Sep 2020 07:43:39 -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=@redhat.com header.s=mimecast20190719 header.b="Tb4u650/"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729438AbgICOlu (ORCPT + 99 others); Thu, 3 Sep 2020 10:41:50 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:59448 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728918AbgICOlh (ORCPT ); Thu, 3 Sep 2020 10:41:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599144094; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dlXSpmpAiY7YS5kYtaeWA3wo80DV7Gum6Jwj3vtpgjg=; b=Tb4u650/EhrjifM8zHaSmMqai3pNgctiuE+sArtWYkPv0tXJjq8Q+5tYaNpfgFkYkhi9av Mz2zf0Uva5qADVd4ap88wtfgYy1GKeLvNccz2lrVxOwXsYzEVeBdvBEOVP9LPucO9UrFV8 q0UNh5Ab8R55tjnoHjXDYJNC3mcQeIY= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-uT69CP2lMYKvBuRTGEBTJw-1; Thu, 03 Sep 2020 10:41:31 -0400 X-MC-Unique: uT69CP2lMYKvBuRTGEBTJw-1 Received: by mail-io1-f70.google.com with SMTP id j4so2169786iob.8 for ; Thu, 03 Sep 2020 07:41:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=dlXSpmpAiY7YS5kYtaeWA3wo80DV7Gum6Jwj3vtpgjg=; b=SwpJYeHdZ9o9RdPhiRIPLMbCK/3LbcCKZ1J/pSrEZ4VRcUggWYPyeArZNRIipkJa2q lJYqPF6UlD/zEdpDRInUJzNyeX5w7qsPPdWAlujV+i4UFDejFxR8bfJFz2N/VjuFVIh6 YLDjB4WKwZgp1TgqegfuyeESbVPFWqucmE2faPfovDjp/X9Aa54WApVz27Ymq6rLzH9X 2YtAbHLqu1x/M9vBV+SYL/av7zZBPcr0+UoN5FnMQZKt6lrs5DzXR03t7fIrMBEyXi8F K1VpaYfXmF8rGrZiwsKT5koddfHt+8zVO3Gvet+PKg4ysUaCKFmHO2MwypQaLhE27kO4 oMZQ== X-Gm-Message-State: AOAM530qz/N7p2voBbujHhVZeg29OfPlxA8H5deMr2vCYYdSJjnU4vr+ bbbsbhnO2STn/O5mcFQCn9SooVnaZlSDkeCN8L99rVPOlpcurivEXCZZdE1WLfYGbmx/ye2iEjj 5VS2maQNCuR/VkOu4oy2RZtN6 X-Received: by 2002:a92:c78e:: with SMTP id c14mr3385275ilk.3.1599144090427; Thu, 03 Sep 2020 07:41:30 -0700 (PDT) X-Received: by 2002:a92:c78e:: with SMTP id c14mr3385251ilk.3.1599144090118; Thu, 03 Sep 2020 07:41:30 -0700 (PDT) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id s16sm1403323iow.47.2020.09.03.07.41.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Sep 2020 07:41:29 -0700 (PDT) Subject: Re: [PATCH] media: dvb-frontends/cxd2099: report errors To: Mauro Carvalho Chehab Cc: jasmin@anw.at, o.endriss@gmx.de, rjkm@metzlerbros.de, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200722134126.31191-1-trix@redhat.com> <20200903161328.62378992@coco.lan> From: Tom Rix Message-ID: Date: Thu, 3 Sep 2020 07:41:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200903161328.62378992@coco.lan> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/3/20 7:13 AM, Mauro Carvalho Chehab wrote: > 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. No, I do not have hw.  I understand your concerns, it is ok if you want to drop this patch, else i'll beef up the warnings. Tom > > So, at most, it could print some warning message for > non-zero return codes. > > > Thanks, > Mauro >