From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x2269touSa1SGijr0Ac0acpJFVNZCKJiRg1jk9NNepP3wy86dWNagFS0mr1Ozm05idbCnH/1J ARC-Seal: i=1; a=rsa-sha256; t=1517256595; cv=none; d=google.com; s=arc-20160816; b=GHNqw3ZQZGfjIcCVW2/L/1QH1M0IADg+mzqHHyJptsFkx7gmVIgVoaidN5l8Th6uon NEw+cbthQusP5nZYZ/wMngp4FlQI+QUbtnMCd9P3wrhHxdgKejilIM/c8EHOgxi7OGNd Gacw0qrkj20Mehzc06AN8cOZOS6BFBndsZlahDaglTo5Voqt8NEizRmKhwBUf9HCLnFB lb+ghbrm/+keaNiGRIrAGWa9ZmaRKsAhltufssRY+7XWvgVy3KHn7JGypKy3YjcaHi9S oeUYWnG+Or6yBy0PEdfIfB6BKFSks2/QrSFjespPuTLdiEJSiEfHd+exp+nDp9QshMFK cpDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=177CmOaOw89gHukC5AoSUgthysVYvAWtHs3nJaaLT0I=; b=aUyJjLVYgqbxuFw+C8FCMQcYaE2fjf0rxHJw+wAeBY1tDBiGaiAqT5YKip3dVH3R4l pGlXwYrR7zSwG6wPnJjxWt6KI7IlWLVmedPCDmJDwgWbVjbzHUd3+oVrVkI7iw4wU18x RgrVTynjQAyIDMU8Kx43xaWxKvjP0hETz4+poOAB2s7jRI59f8FO9IPerLUqiLh00Ojq AerhHHqXahzylVE8OUMfgew2SL8ublSqtjBRsrRo9X9scH+DpdOe7srTCYUtZCvLcJtR /sRPZmV1cSk3hJbJlpHMp4wsBd7tOSnZWzNa9fRXVj9OGZ0SskyEPkhHb6Snaj4TH5kz /qHg== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiao Liang , Thomas Gleixner Subject: [PATCH 4.9 56/66] perf/x86/amd/power: Do not load AMD power module on !AMD platforms Date: Mon, 29 Jan 2018 13:57:20 +0100 Message-Id: <20180129123842.849951138@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123839.842860149@linuxfoundation.org> References: <20180129123839.842860149@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590932461351172480?= X-GMAIL-MSGID: =?utf-8?q?1590958852260697427?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xiao Liang commit 40d4071ce2d20840d224b4a77b5dc6f752c9ab15 upstream. The AMD power module can be loaded on non AMD platforms, but unload fails with the following Oops: BUG: unable to handle kernel NULL pointer dereference at (null) IP: __list_del_entry_valid+0x29/0x90 Call Trace: perf_pmu_unregister+0x25/0xf0 amd_power_pmu_exit+0x1c/0xd23 [power] SyS_delete_module+0x1a8/0x2b0 ? exit_to_usermode_loop+0x8f/0xb0 entry_SYSCALL_64_fastpath+0x20/0x83 Return -ENODEV instead of 0 from the module init function if the CPU does not match. Fixes: c7ab62bfbe0e ("perf/x86/amd/power: Add AMD accumulated power reporting mechanism") Signed-off-by: Xiao Liang Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/20180122061252.6394-1-xiliang@redhat.com Signed-off-by: Greg Kroah-Hartman --- arch/x86/events/amd/power.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/events/amd/power.c +++ b/arch/x86/events/amd/power.c @@ -277,7 +277,7 @@ static int __init amd_power_pmu_init(voi int ret; if (!x86_match_cpu(cpu_match)) - return 0; + return -ENODEV; if (!boot_cpu_has(X86_FEATURE_ACC_POWER)) return -ENODEV;