From patchwork Mon Jun 24 19:57:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 2773491 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9E23FC0AB1 for ; Mon, 24 Jun 2013 19:59:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 637B320123 for ; Mon, 24 Jun 2013 19:59:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1482A2028F for ; Mon, 24 Jun 2013 19:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751458Ab3FXT6t (ORCPT ); Mon, 24 Jun 2013 15:58:49 -0400 Received: from mail.ispras.ru ([83.149.199.45]:43176 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775Ab3FXT6s (ORCPT ); Mon, 24 Jun 2013 15:58:48 -0400 Received: from localhost.localdomain (ppp85-141-255-123.pppoe.mtu-net.ru [85.141.255.123]) by mail.ispras.ru (Postfix) with ESMTPSA id A7B5854015B; Mon, 24 Jun 2013 23:58:46 +0400 (MSK) From: Alexey Khoroshilov To: Huang Shijie , Hans Verkuil Cc: Alexey Khoroshilov , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH 2/2] [media] tlg2300: fix checking firmware in poseidon_probe() Date: Mon, 24 Jun 2013 23:57:37 +0400 Message-Id: <1372103857-29451-2-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1372103857-29451-1-git-send-email-khoroshilov@ispras.ru> References: <1372103857-29451-1-git-send-email-khoroshilov@ispras.ru> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP check_firmware() makes sure firmware is in a device. It returns zero on success and error code otherwise. Also it sets down_firmware flag to 1 if downloading occurs. The only caller poseidon_probe() checks down_firmware flag and returns 0 without any initialization if it is set. That looks very strange, so the patch removes down_firmware argument of check_firmware() and returns error code if check_firmware() fails in poseidon_probe(). Not tested on real hardware. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov --- drivers/media/usb/tlg2300/pd-main.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c index ca5e1bc..95f94e5 100644 --- a/drivers/media/usb/tlg2300/pd-main.c +++ b/drivers/media/usb/tlg2300/pd-main.c @@ -375,7 +375,7 @@ static inline void set_map_flags(struct poseidon *pd, struct usb_device *udev) } #endif -static int check_firmware(struct usb_device *udev, int *down_firmware) +static int check_firmware(struct usb_device *udev) { void *buf; int ret; @@ -395,10 +395,8 @@ static int check_firmware(struct usb_device *udev, int *down_firmware) USB_CTRL_GET_TIMEOUT); kfree(buf); - if (ret < 0) { - *down_firmware = 1; + if (ret < 0) return firmware_download(udev); - } return 0; } @@ -411,9 +409,9 @@ static int poseidon_probe(struct usb_interface *interface, int new_one = 0; /* download firmware */ - check_firmware(udev, &ret); + ret = check_firmware(udev); if (ret) - return 0; + return ret; /* Do I recovery from the hibernate ? */ pd = find_old_poseidon(udev);