Message ID | 20200401161520.919936172@linuxfoundation.org |
---|---|
State | Superseded |
Headers | show
Return-Path: <SRS0=zuZT=5R=vger.kernel.org=stable-owner@kernel.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A867C2D0F2 for <stable@archiver.kernel.org>; Wed, 1 Apr 2020 16:53:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 103162063A for <stable@archiver.kernel.org>; Wed, 1 Apr 2020 16:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585760010; bh=EqfmkvcYZIMbDwHY7Y9clByYbz047wdHWOhkUFeTWUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RO6XsDPkd0a6KS4e+7MwPUAlRNI6QijPBASVjvj3d2uto0ZyWiBZhwWOIBX2fp0Qk Ey8yXuubKoGtIDeASH9RLUsAzoHTpru11SEdplebWlMtw4ibH9TUfl1Kox5PXbEAUY Mu92crCnEjzki4DS0yEf3AS9xg5DgVQJ6Lw6m4Wo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388403AbgDAQcU (ORCPT <rfc822;stable@archiver.kernel.org>); Wed, 1 Apr 2020 12:32:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:58708 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388378AbgDAQcT (ORCPT <rfc822;stable@vger.kernel.org>); Wed, 1 Apr 2020 12:32:19 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 427582063A; Wed, 1 Apr 2020 16:32:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585758738; bh=EqfmkvcYZIMbDwHY7Y9clByYbz047wdHWOhkUFeTWUM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z4bFnFrLgBZj9J+Z6wyyC32Soyc48aaEbq1TZw8cxz+DNd9hw7zTkLxB2thrqhbC5 ku0kFG3xOLPDOgMXncEO5zGLMYBCRblQlb8zGpdLS/kCeVyq+95POZSLrdf0lmqmRS 8HKlAC3x3sRAPW8GO0uZUbFmlbnJ8X2B9ILEGqOA= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Chunguang Xu <brookxu@tencent.com>, Andrew Morton <akpm@linux-foundation.org>, Michal Hocko <mhocko@suse.com>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, Johannes Weiner <hannes@cmpxchg.org>, Vladimir Davydov <vdavydov.dev@gmail.com>, Linus Torvalds <torvalds@linux-foundation.org> Subject: [PATCH 4.4 22/91] memcg: fix NULL pointer dereference in __mem_cgroup_usage_unregister_event Date: Wed, 1 Apr 2020 18:17:18 +0200 Message-Id: <20200401161520.919936172@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200401161512.917494101@linuxfoundation.org> References: <20200401161512.917494101@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
--- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -3480,7 +3480,7 @@ static void __mem_cgroup_usage_unregiste struct mem_cgroup_thresholds *thresholds; struct mem_cgroup_threshold_ary *new; unsigned long usage; - int i, j, size; + int i, j, size, entries; mutex_lock(&memcg->thresholds_lock); @@ -3500,14 +3500,20 @@ static void __mem_cgroup_usage_unregiste __mem_cgroup_threshold(memcg, type == _MEMSWAP); /* Calculate new number of threshold */ - size = 0; + size = entries = 0; for (i = 0; i < thresholds->primary->size; i++) { if (thresholds->primary->entries[i].eventfd != eventfd) size++; + else + entries++; } new = thresholds->spare; + /* If no items related to eventfd have been cleared, nothing to do */ + if (!entries) + goto unlock; + /* Set thresholds array to NULL if we don't have thresholds */ if (!size) { kfree(new);