From patchwork Thu Nov 29 16:38:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 10704873 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B622D13A4 for ; Thu, 29 Nov 2018 16:38:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A51062F58E for ; Thu, 29 Nov 2018 16:38:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9917B2F5B4; Thu, 29 Nov 2018 16:38:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62BE32F617 for ; Thu, 29 Nov 2018 16:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729283AbeK3DoZ (ORCPT ); Thu, 29 Nov 2018 22:44:25 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:38143 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728136AbeK3DoZ (ORCPT ); Thu, 29 Nov 2018 22:44:25 -0500 Received: by mail-pl1-f196.google.com with SMTP id e5so1302074plb.5 for ; Thu, 29 Nov 2018 08:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s4KAWB8thmpYH1WwjCgumPIS1PyiX7+UJj97tYgIK5o=; b=ZHuUacuiSSYMQEtgRUiXKlj3vykdcFrM2GcB2KYfq7rKkw8B3kfMoDOPlUyuekZ1BL 10x4k4jwYAZhq9LHCN1sh0lhH7vuZcXVjqXot5mt9c8q3y7TsMJtxDTdBlexFrFPUfGy P+/orrYrGhSDcz/uIykP7tGUzT8p+hyRF5qS0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s4KAWB8thmpYH1WwjCgumPIS1PyiX7+UJj97tYgIK5o=; b=rOoXgO4FdBlGbQzYqWSQH8+RGZsbOTRMA/70+OFONwXMHSv1Uy84yOW5PU+Ey9jRKZ i5hi1jEBqXmH9oEVWkdBi1gRm3ev/5A0R6OuVSq5RL1DxlMmmX6h6fl2cncLaxZDEpPc Jxsq7iMqPnY8wx0yRw5BAvXH88a/qnVTRHsUUhB6ca7U69QmHiu3x3VYD2CXnUoZJ6Ip keU7FfVpclz4Im+k7MftOr7A13WatsziGN+Efwxvjy8i7BuuC7kCnhJ9J8P9AoO6z+Ge AHlAsTNkPKqWcouq6drEAoNSAPhGuMKLISs6iq2I9MxTByHGSZUrCpWFBfs+bNcnm4RM N2vQ== X-Gm-Message-State: AA+aEWae2DB9LXgWm/edAZ6qL1ExVzV+Bta3MP9DpxfUxDDukLhnNJBI dQhQ/aNe+WMjgMZHVTU7ps3hRA== X-Google-Smtp-Source: AFSGD/Wsg40NT0WJBkAv5b8UhC82zU0+NQCzi6mFuMdjDjr6DS35UublCovKp/d0QS/0dJgUMQ2Djg== X-Received: by 2002:a17:902:5a4d:: with SMTP id f13mr2219688plm.49.1543509508040; Thu, 29 Nov 2018 08:38:28 -0800 (PST) Received: from smtp.gmail.com ([2620:15c:202:1:fed3:9637:a13a:6c15]) by smtp.gmail.com with ESMTPSA id s37sm3033836pgm.19.2018.11.29.08.38.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 08:38:27 -0800 (PST) From: Stephen Boyd To: Andy Gross Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Stephen Rothwell , kbuild test robot , Jordan Crouse , Bjorn Andersson , Evan Green , Rob Clark Subject: [PATCH] drm: msm: Check cmd_db_read_aux_data() for failure Date: Thu, 29 Nov 2018 08:38:26 -0800 Message-Id: <20181129163826.178670-1-swboyd@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need to check the call to cmd_db_read_aux_data() for the error case, so that we don't continue and use potentially uninitialized values for 'pri_count' and 'sec_count'. Otherwise, we get the following compiler warnings: drivers/gpu/drm/msm/adreno/a6xx_gmu.c: In function 'a6xx_gmu_rpmh_arc_votes_init.isra.12': drivers/gpu/drm/msm/adreno/a6xx_gmu.c:943:12: warning: 'pri_count' is used uninitialized in this function [-Wuninitialized] pri_count >>= 1; ^~~ drivers/gpu/drm/msm/adreno/a6xx_gmu.c:948:12: warning: 'sec_count' may be used uninitialized in this function [-Wmaybe-uninitialized] sec_count >>= 1; ^~~ Reported-by: Stephen Rothwell Reported-by: kbuild test robot Cc: Jordan Crouse Cc: Bjorn Andersson Cc: Evan Green Cc: Jordan Crouse Cc: Rob Clark Fixes: ed3cafa79ea7 ("soc: qcom: cmd-db: Stop memcpy()ing in cmd_db_read_aux_data()") Signed-off-by: Stephen Boyd Reviewed-by: Andy Gross Acked-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c index 8cd294e2846d..b450f7ea0422 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -936,6 +936,8 @@ static int a6xx_gmu_rpmh_arc_votes_init(struct device *dev, u32 *votes, size_t pri_count, sec_count; pri = cmd_db_read_aux_data(id, &pri_count); + if (IS_ERR(pri)) + return PTR_ERR(pri); /* * The data comes back as an array of unsigned shorts so adjust the * count accordingly @@ -945,6 +947,9 @@ static int a6xx_gmu_rpmh_arc_votes_init(struct device *dev, u32 *votes, return -EINVAL; sec = cmd_db_read_aux_data("mx.lvl", &sec_count); + if (IS_ERR(sec)) + return PTR_ERR(sec); + sec_count >>= 1; if (!sec_count) return -EINVAL;