From patchwork Wed Dec 2 11:58:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin King X-Patchwork-Id: 7745361 Return-Path: X-Original-To: patchwork-linux-acpi@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 82E21BEEE1 for ; Wed, 2 Dec 2015 11:58:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8FAC920483 for ; Wed, 2 Dec 2015 11:58:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A78FD20632 for ; Wed, 2 Dec 2015 11:58:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758006AbbLBL6d (ORCPT ); Wed, 2 Dec 2015 06:58:33 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:41097 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754604AbbLBL6d (ORCPT ); Wed, 2 Dec 2015 06:58:33 -0500 Received: from 1.general.cking.us.vpn ([10.172.65.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1a463K-0005n4-Mb; Wed, 02 Dec 2015 11:58:31 +0000 From: Colin King To: "Rafael J . Wysocki" , Len Brown , linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] ACPI / extlog: don't dereference extlog_l1_addr if it is null Date: Wed, 2 Dec 2015 11:58:28 +0000 Message-Id: <1449057508-10172-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.6.2 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 From: Colin Ian King There is a check to see if extlog_l1_addr is null before calling acpi_os_unmap_iomem, however, before that call there is a dereference on this that could trip an oops. Move the extlog_l1_addr dereference so it occurs only if it is not null. Found by static analysis by smatch. Signed-off-by: Colin Ian King --- drivers/acpi/acpi_extlog.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/acpi/acpi_extlog.c b/drivers/acpi/acpi_extlog.c index b3842ff..183b7b2 100644 --- a/drivers/acpi/acpi_extlog.c +++ b/drivers/acpi/acpi_extlog.c @@ -309,9 +309,10 @@ static void __exit extlog_exit(void) { set_edac_report_status(old_edac_report_status); mce_unregister_decode_chain(&extlog_mce_dec); - ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN; - if (extlog_l1_addr) + if (extlog_l1_addr) { + ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN; acpi_os_unmap_iomem(extlog_l1_addr, l1_size); + } if (elog_addr) acpi_os_unmap_iomem(elog_addr, elog_size); release_mem_region(elog_base, elog_size);