From patchwork Thu May 18 19:09:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 9735083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id EF68E601A1 for ; Thu, 18 May 2017 19:09:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBCC4289F1 for ; Thu, 18 May 2017 19:09:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0BEF289FD; Thu, 18 May 2017 19:09:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_NUMERIC_HELO autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98649289F1 for ; Thu, 18 May 2017 19:09:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756183AbdERTJH (ORCPT ); Thu, 18 May 2017 15:09:07 -0400 Received: from gateway21.websitewelcome.com ([192.185.45.147]:44946 "EHLO gateway21.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755215AbdERTJG (ORCPT ); Thu, 18 May 2017 15:09:06 -0400 Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway21.websitewelcome.com (Postfix) with ESMTP id AB396400DEF1B for ; Thu, 18 May 2017 14:09:02 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id BQn1dFXeWnpMZBQn1dJoJw; Thu, 18 May 2017 14:08:47 -0500 Received: from gator4166.hostgator.com ([108.167.133.22]:15524) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1dBQnF-000P1s-Cc; Thu, 18 May 2017 14:09:01 -0500 Received: from 189.152.179.187 ([189.152.179.187]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Thu, 18 May 2017 14:09:01 -0500 Date: Thu, 18 May 2017 14:09:01 -0500 Message-ID: <20170518140901.Horde.bHPlhISMuTRMEbVjfq3p1kd@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Malcolm Priestley , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [media-dvb-usb-v2] question about value overwrite User-Agent: Horde Application Framework 5 MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Exim-ID: 1dBQnF-000P1s-Cc X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:15524 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 2 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hello everybody, While looking into Coverity ID 1226934 I ran into the following piece of code at drivers/media/usb/dvb-usb-v2/lmedm04.c:205 205static int lme2510_stream_restart(struct dvb_usb_device *d) 206{ 207 struct lme2510_state *st = d->priv; 208 u8 all_pids[] = LME_ALL_PIDS; 209 u8 stream_on[] = LME_ST_ON_W; 210 int ret; 211 u8 rbuff[1]; 212 if (st->pid_off) 213 ret = lme2510_usb_talk(d, all_pids, sizeof(all_pids), 214 rbuff, sizeof(rbuff)); 215 /*Restart Stream Command*/ 216 ret = lme2510_usb_talk(d, stream_on, sizeof(stream_on), 217 rbuff, sizeof(rbuff)); 218 return ret; 219} The issue is that the value store in variable _ret_ at line 213 is overwritten by the one stored at line 216, before it can be used. My question is if an _else_ statement is missing, or the variable assignment at line 213 should be removed, leaving just the call lme2510_usb_talk(d, all_pids, sizeof(all_pids), rbuff, sizeof(rbuff)); in place. Maybe either of the following patches could be applied: index 924adfd..d573144 100644 What do you think? I'd really appreciate any comment on this. Thank you! --- Gustavo A. R. Silva --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -207,15 +207,15 @@ static int lme2510_stream_restart(struct dvb_usb_device *d) struct lme2510_state *st = d->priv; u8 all_pids[] = LME_ALL_PIDS; u8 stream_on[] = LME_ST_ON_W; - int ret; u8 rbuff[1]; + if (st->pid_off) - ret = lme2510_usb_talk(d, all_pids, sizeof(all_pids), + lme2510_usb_talk(d, all_pids, sizeof(all_pids), rbuff, sizeof(rbuff)); + /*Restart Stream Command*/ - ret = lme2510_usb_talk(d, stream_on, sizeof(stream_on), + return lme2510_usb_talk(d, stream_on, sizeof(stream_on), rbuff, sizeof(rbuff)); - return ret; } index 924adfd..dd51f05 100644 --- a/drivers/media/usb/dvb-usb-v2/lmedm04.c +++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c @@ -207,15 +207,15 @@ static int lme2510_stream_restart(struct dvb_usb_device *d) struct lme2510_state *st = d->priv; u8 all_pids[] = LME_ALL_PIDS; u8 stream_on[] = LME_ST_ON_W; - int ret; u8 rbuff[1]; + if (st->pid_off) - ret = lme2510_usb_talk(d, all_pids, sizeof(all_pids), + return lme2510_usb_talk(d, all_pids, sizeof(all_pids), rbuff, sizeof(rbuff)); - /*Restart Stream Command*/ - ret = lme2510_usb_talk(d, stream_on, sizeof(stream_on), + else + /*Restart Stream Command*/ + return lme2510_usb_talk(d, stream_on, sizeof(stream_on), rbuff, sizeof(rbuff)); - return ret; }