From patchwork Wed Dec 6 22:33:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wessel X-Patchwork-Id: 120909 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp7625837qgn; Wed, 6 Dec 2017 14:34:30 -0800 (PST) X-Google-Smtp-Source: AGs4zMbIVVij7UFHuKcftRHKeKumrK0B0+q1xecoMjzsXNSD5MXmMc2oJsEpwgqnHNMut7d5Lj/p X-Received: by 10.101.77.202 with SMTP id q10mr21863231pgt.95.1512599670722; Wed, 06 Dec 2017 14:34:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512599670; cv=none; d=google.com; s=arc-20160816; b=ATjVnxgqdZEv5dG/zpVV8oJGwtlEHdnXO9Gmg2NE1tGJlUTSszQE/CwbgYzgjRgRM5 dCqe6F1oo0o8w0zS5BV79j0m1voWEskuRXfwJ7mfVblzHyvwJPy1IN+t3wpdu/4U1N0U Vewov8gbR2WUqH2OCmQZVHh9z8Q7LVrZ4yAsyG/OsJwAYHpej5PTVKBxxbGmijnpA3hz IITpei6SVh3pxuEsfOS6q3bHcmvScVphJrkkmFFE9Roe+hjp+FEa40jBDv0zaknDMzDg SbjZ08kPsWrpbInvt+6xLIdxfAtdx4AdquCYvjt9FbwW+ddlHiSezIuiNeUapaspZMOS zZIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=ILjWZvubJKotTVAoEgBzrE9mefIhSmU4LZ64uRoHj1w=; b=zY5PX3o8kNHUp8TYbiYCitbKqSTjXx31j0CWdCmXqMCB+4EZq5h/DRB3N4GP7Lkuvh 9FvS4L3YA/xpgrajPCR6f4wVs32Pu3ElGz0Iz73j/AR14nWJJrwGIvFoKOYEyy4UZafS Bht5YMIQ5EfbFm5ViFZmtjJYq3xK2DetEAzigl9Pg6XvD29RiZPcF5b/APjMz+HQU1ZO LISxRvuw8vGd+ruOHgfmRoTZ7BxQWHJGsGXEZhuGMXxKEdsOZJWnKUCsDhP3NpGsCrGf vsbY0vUyAVHefyg8rY/YqTBcbOR0GKyad40e5uu5aJYBc3QCZEjzOurRAyyT7gepoBkN L/Yg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a34si2661564pld.248.2017.12.06.14.34.30; Wed, 06 Dec 2017 14:34:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752362AbdLFWeA (ORCPT + 23 others); Wed, 6 Dec 2017 17:34:00 -0500 Received: from mail1.windriver.com ([147.11.146.13]:39417 "EHLO mail1.windriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751598AbdLFWd6 (ORCPT ); Wed, 6 Dec 2017 17:33:58 -0500 Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id vB6MXpks011524 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Wed, 6 Dec 2017 14:33:51 -0800 (PST) Received: from ord-jrw-virt2.wrs.com (172.25.59.212) by ALA-HCA.corp.ad.wrs.com (147.11.189.40) with Microsoft SMTP Server id 14.3.361.1; Wed, 6 Dec 2017 14:33:50 -0800 From: Jason Wessel To: CC: , Subject: [PATCH 1/2] kdb: Fix handling of kallsyms_symbol_next() return value Date: Wed, 6 Dec 2017 16:33:44 -0600 Message-ID: <1512599625-388-2-git-send-email-jason.wessel@windriver.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1512599625-388-1-git-send-email-jason.wessel@windriver.com> References: <1512599625-388-1-git-send-email-jason.wessel@windriver.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Daniel Thompson kallsyms_symbol_next() returns a boolean (true on success). Currently kdb_read() tests the return value with an inequality that unconditionally evaluates to true. This is fixed in the obvious way and, since the conditional branch is supposed to be unreachable, we also add a WARN_ON(). Reported-by: Dan Carpenter Signed-off-by: Daniel Thompson Cc: linux-stable Signed-off-by: Jason Wessel --- kernel/debug/kdb/kdb_io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 1.9.1 diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index e74be38..ed5d349 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -350,7 +350,7 @@ static char *kdb_read(char *buffer, size_t bufsize) } kdb_printf("\n"); for (i = 0; i < count; i++) { - if (kallsyms_symbol_next(p_tmp, i) < 0) + if (WARN_ON(!kallsyms_symbol_next(p_tmp, i))) break; kdb_printf("%s ", p_tmp); *(p_tmp + len) = '\0';