From patchwork Thu Oct 2 08:16:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Georgi X-Patchwork-Id: 395846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 76A47140180 for ; Thu, 2 Oct 2014 18:22:12 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751583AbaJBIWK (ORCPT ); Thu, 2 Oct 2014 04:22:10 -0400 Received: from georgi-clan.de ([78.47.195.38]:44984 "EHLO georgi-clan.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751400AbaJBIWI (ORCPT ); Thu, 2 Oct 2014 04:22:08 -0400 Received: from office.lan (drms-4d0def9c.pool.mediaWays.net [77.13.239.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: patrick) by georgi-clan.de (Postfix) with ESMTPSA id CF6DE2214D8; Thu, 2 Oct 2014 10:16:30 +0200 (CEST) From: Patrick Georgi To: linux-tegra@vger.kernel.org Cc: Patrick Georgi Subject: [PATCH 4/5] set: check seek success Date: Thu, 2 Oct 2014 10:16:27 +0200 Message-Id: <1412237788-20611-4-git-send-email-patrick@georgi-clan.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1412237788-20611-1-git-send-email-patrick@georgi-clan.de> References: <1412237788-20611-1-git-send-email-patrick@georgi-clan.de> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org This could silently fail which leads to surprising behaviour. Found-by: Coverity Scan Signed-off-by: Patrick Georgi --- src/set.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/set.c b/src/set.c index ff32b53..907d640 100644 --- a/src/set.c +++ b/src/set.c @@ -59,7 +59,11 @@ read_from_image(char *filename, return result; } - fseek(fp, offset, SEEK_SET); + if (!fseek(fp, offset, SEEK_SET)) { + printf("Error: Couldn't seek to %s(%d)\n", filename, offset); + result = 1; + goto cleanup; + } if (stat(filename, &stats) != 0) { printf("Error: Unable to query info on bootloader path %s\n",