From patchwork Thu Sep 17 10:12:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 7205601 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A017BEEC1 for ; Thu, 17 Sep 2015 10:14:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9C877207D1 for ; Thu, 17 Sep 2015 10:14:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8109207C3 for ; Thu, 17 Sep 2015 10:14:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcWC1-0005Lq-AX; Thu, 17 Sep 2015 10:13:29 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZcWBy-00059y-Sw for linux-arm-kernel@lists.infradead.org; Thu, 17 Sep 2015 10:13:27 +0000 Received: by pacfv12 with SMTP id fv12so16909264pac.2 for ; Thu, 17 Sep 2015 03:13:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=FGep5oTsiim8s2ESby5KJlOHHP70lNeJ/4DJ1Rgo/W0=; b=iJ8AiScmacWIurfpdZU5JJ07YExXR9WUpXXa3MyBC0P12CtKLgbF3iTtzkXMpNSFiD zXRhm5eB5ejy+TVp/MqeFhFGn2EPNOv3FTPCcTaIy/dhJDZhLjt0gZ+Ki0VXnr5UgaGj N2l3wlXsbzv1raFW8xmticcDfhnWFTsP4EKdTaBLjRLXTtBTlQVPMkJF9VhOcwtCGstP FUt2eCye85rkjFNRHbixwqDl7cqjapo12lKNoH9aeKLrQ+eoIfUfg7cBeblUCUf7TCLw mldY3byA/EK6HDSbrxtHL3VZmcZNEjz99bJOiovqYxwo8mMBEI8bCwU4Z5ZjuqvoZPKC mf6g== X-Received: by 10.66.226.37 with SMTP id rp5mr71506641pac.49.1442484785577; Thu, 17 Sep 2015 03:13:05 -0700 (PDT) Received: from localhost.localdomain ([49.206.249.64]) by smtp.gmail.com with ESMTPSA id tc8sm2744287pbc.43.2015.09.17.03.13.01 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Sep 2015 03:13:04 -0700 (PDT) From: Sudip Mukherjee To: Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard , Mauro Carvalho Chehab Subject: [PATCH] [media] c8sectpfe: fix return of garbage Date: Thu, 17 Sep 2015 15:42:54 +0530 Message-Id: <1442484774-20449-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150917_031326_979217_6DB79901 X-CRM114-Status: GOOD ( 14.66 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sudip Mukherjee , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kernel@stlinux.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 The variable err was never initialized, that means we had been checking a garbage value in the for loop. Moreover if the segment is not outside the firmware file then also we have been returning the garbage. Initialize it to 0 so that on success we return the value and no need to check in the for loop also as it is initially 0 and whenever that value changes we have done a break from the loop. Signed-off-by: Sudip Mukherjee --- drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c index 486aef5..8688fe2 100644 --- a/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c +++ b/drivers/media/platform/sti/c8sectpfe/c8sectpfe-core.c @@ -1097,7 +1097,7 @@ static int load_slim_core_fw(const struct firmware *fw, void *context) Elf32_Ehdr *ehdr; Elf32_Phdr *phdr; u8 __iomem *dst; - int err, i; + int err = 0, i; if (!fw || !context) return -EINVAL; @@ -1106,7 +1106,7 @@ static int load_slim_core_fw(const struct firmware *fw, void *context) phdr = (Elf32_Phdr *)(fw->data + ehdr->e_phoff); /* go through the available ELF segments */ - for (i = 0; i < ehdr->e_phnum && !err; i++, phdr++) { + for (i = 0; i < ehdr->e_phnum; i++, phdr++) { /* Only consider LOAD segments */ if (phdr->p_type != PT_LOAD)