Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp730711ybc; Sat, 16 Nov 2019 07:42:52 -0800 (PST) X-Google-Smtp-Source: APXvYqznhg4qjjeJFe+5Rn3HwOe2K/OoZNmZKT6bXJdNyNGAx4sXPMxReRtD3zJhBtjIjraO+BI3 X-Received: by 2002:a17:906:1342:: with SMTP id x2mr10718638ejb.304.1573918972369; Sat, 16 Nov 2019 07:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573918972; cv=none; d=google.com; s=arc-20160816; b=Qrhxji5vlIbP/uAvJMY1tyBPukayKSdT/FzO+UBLRpfrkbjTHKa2FvyOJ/i8vkgIea X9a0rqblRVdlyrvDvxpmMKoPUJoxdwmW7sFxU8rvwfz1QgD0GlrJ0I5vYl4CUOKSZzsg F12baU+jAsX31ns2yMUrGm1oso3HCMCi65KbpvAilvMaV7Lq1hYkzLTsDYajZKi1w9Qc ipA6nnHh/y1lRsXEnfQnF0C/XgHRtWh1mBe8A2pz3xcElp+jHLaF22S0UFuJAVsxfMRp HvIM+8cIZTls9CWKfYvQ8XtdxPOTIqkUw+FP9NJs+1oiWEud49L5p2OqCRVhtNm5/eBS mflA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QQRPJXcrkaPhhhI8hD3x7kAAFaWsWkgrXFaPDw7vFhQ=; b=VPXZ6VK5fiqUq+48YG/PZet1ZhFcjz0no4Y5MDIuNUZj/LAdiypPd8XlVYarfttuzx 8MfAOBMgpWlQ/6tipTds+sKs7pWbO0BhfooAn2RNQhZEUO0x0yGmCHlqyBiYNVTvYb4+ m8qxHrYFaEkfN2+7EP+wvVUgPcCixBOeD5M8ohALI+avslqWKDuhdwGCEaFq2ha/Zp4M so+gWfO4+NXR2OrTRlY4lQ5etDDAync5FMbJjdWN/X2DjCR2xa1L68F1SscJr/UVT6jy Z16NR2PsYYa1t/fh2TxFBzmbxpzOfZ/tnsgIdhvlUsxb6jGzxfzwEJJ8bNjxh9qSvXKZ er2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="HE/rOSQz"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c24si7655874ejs.366.2019.11.16.07.42.28; Sat, 16 Nov 2019 07:42:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="HE/rOSQz"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727851AbfKPPlV (ORCPT + 99 others); Sat, 16 Nov 2019 10:41:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:44308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727830AbfKPPlU (ORCPT ); Sat, 16 Nov 2019 10:41:20 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6C33820730; Sat, 16 Nov 2019 15:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573918879; bh=uWZClTrsqmEFx8byq1mK09fgpItzYGHhc8KLTIkX/1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HE/rOSQzwYjhIJpIj6M2ykxTXZuh5t+0d8DsU4R1oH8lifnaJ5J8nrSOhr5ifxBo/ sLlciVkJtFvRGa7vy07LaqaIbxPww3lkZ0YGFTNkbBHme/LouxZTyyeTj6m+piSODK +QCVt51DRL2/wDmH3DrFf/48dcCou/MugiEOnXc4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Geoff Levand , Michael Ellerman , Sasha Levin , linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 010/237] powerpc: Fix signedness bug in update_flash_db() Date: Sat, 16 Nov 2019 10:37:25 -0500 Message-Id: <20191116154113.7417-10-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 014704e6f54189a203cc14c7c0bb411b940241bc ] The "count < sizeof(struct os_area_db)" comparison is type promoted to size_t so negative values of "count" are treated as very high values and we accidentally return success instead of a negative error code. This doesn't really change runtime much but it fixes a static checker warning. Signed-off-by: Dan Carpenter Acked-by: Geoff Levand Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/platforms/ps3/os-area.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c index cdbfc5cfd6f38..f5387ad822798 100644 --- a/arch/powerpc/platforms/ps3/os-area.c +++ b/arch/powerpc/platforms/ps3/os-area.c @@ -664,7 +664,7 @@ static int update_flash_db(void) db_set_64(db, &os_area_db_id_rtc_diff, saved_params.rtc_diff); count = os_area_flash_write(db, sizeof(struct os_area_db), pos); - if (count < sizeof(struct os_area_db)) { + if (count < 0 || count < sizeof(struct os_area_db)) { pr_debug("%s: os_area_flash_write failed %zd\n", __func__, count); error = count < 0 ? count : -EIO; -- 2.20.1