Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2216993imm; Mon, 28 May 2018 04:08:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrHCihhCHxMx4dD3r/6gqIWMdzd3MadO1FkVRPHBGqbhcXXFtWwxsEia2pr3KT+wDx5Yo7C X-Received: by 2002:a62:8910:: with SMTP id v16-v6mr12805536pfd.13.1527505704066; Mon, 28 May 2018 04:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527505704; cv=none; d=google.com; s=arc-20160816; b=dYWrer9Lj8/iVsUR8aYKMF9U32EVxjxwyAV4Ct9fhsClesvhi/x/uC2giFHvG8z0mr pGAbZawPo+NS3AM/z2xLKm7u4nC5hOaTYHx4rE9qoso0nXzsZ+doRf5I31jrsUi1y0BU tBZNt4p0uTaJ1+qnPHBR7ksD218Kff2ef/jl0yb/3gRkxPLaRFbaAnvUUaXlEs+zEFEP zexX07rTLu7xUyLJC9jQNddi+Bvq19jNQBI0Lr/FSBbOIv1cuP8UUKVEgkqQpjbLjPXD t5tcZRantH1NcZAabf4mxJG96zWZbAl9uwiJAubGbMTBHen8mRZ5lToN7jmBxStgeRs3 O0uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=i6em40SNPUQE0gcQ/8XFB/SC3vjmgRYF2rvmFYEUfXY=; b=VdSqTCLX5UBuuUUbUhmYs8C4HQrR31exWThwrV4780J0jAO1GdsfFiY1YPVw7i+VRc L9+CAP/0+bPjZUgfea6ol/V5TYlqM3yS6Wy1+3mxxvgXCkWpeXBdbiTdX/GnROCx2bWS +bcM/cdLTfWA15wKSqSuZBZ9C0rTkJR0WWMbdVhf5YjVhYSusAmZwIV1fvqfl/4cx583 asmgDNW5tpd6oJQWRNYl1lNB21CjIkg2H5h3Oi0aiWSYavIz84kC9BsmOW1l5XDDT+4K 8hfSCDsLEnErmC7d/tNDqwYwIkSI3tCnhGbDqHfHypvRj9/cjGVcO31JKe1fMZTVnZ3v Fe9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D0w7KkwP; 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 r15-v6si5573855pgn.498.2018.05.28.04.08.09; Mon, 28 May 2018 04:08:24 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=D0w7KkwP; 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 S1423371AbeE1LHH (ORCPT + 99 others); Mon, 28 May 2018 07:07:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:53706 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423342AbeE1LG4 (ORCPT ); Mon, 28 May 2018 07:06:56 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 A8DF82086D; Mon, 28 May 2018 11:06:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527505616; bh=Pfy6EvBli9ws3FMujxs9mBaeYjtU5YSEuHHqghBuOAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D0w7KkwP1taRxjWmK5UtQGaO/0WpMDjw+s3OUyYOc1On5pnJ5vbFPQp5KB+wjE1xN ooc6DJtlHRF1XkkvKCty8TxdNr+bXHkmJIpg2Dm2U7b6011GXTlnnfaBc2g7pFiRdS 7GgZ+pYV30gxvF147DITggV6XQQGMPd29jn9VhSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Christoph Hellwig , Ming Lei , Sasha Levin Subject: [PATCH 4.16 067/272] genirq/affinity: Dont return with empty affinity masks on error Date: Mon, 28 May 2018 12:01:40 +0200 Message-Id: <20180528100246.534540714@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100240.256525891@linuxfoundation.org> References: <20180528100240.256525891@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Gleixner [ Upstream commit 0211e12dd0a5385ecffd3557bc570dbad7fcf245 ] When the allocation of node_to_possible_cpumask fails, then irq_create_affinity_masks() returns with a pointer to the empty affinity masks array, which will cause malfunction. Reorder the allocations so the masks array allocation comes last and every failure path returns NULL. Fixes: 9a0ef98e186d ("genirq/affinity: Assign vectors to all present CPUs") Signed-off-by: Thomas Gleixner Cc: Christoph Hellwig Cc: Ming Lei Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/irq/affinity.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) --- a/kernel/irq/affinity.c +++ b/kernel/irq/affinity.c @@ -108,7 +108,7 @@ irq_create_affinity_masks(int nvecs, con int affv = nvecs - affd->pre_vectors - affd->post_vectors; int last_affv = affv + affd->pre_vectors; nodemask_t nodemsk = NODE_MASK_NONE; - struct cpumask *masks; + struct cpumask *masks = NULL; cpumask_var_t nmsk, *node_to_possible_cpumask; /* @@ -121,13 +121,13 @@ irq_create_affinity_masks(int nvecs, con if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL)) return NULL; - masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL); - if (!masks) - goto out; - node_to_possible_cpumask = alloc_node_to_possible_cpumask(); if (!node_to_possible_cpumask) - goto out; + goto outcpumsk; + + masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL); + if (!masks) + goto outnodemsk; /* Fill out vectors at the beginning that don't need affinity */ for (curvec = 0; curvec < affd->pre_vectors; curvec++) @@ -192,8 +192,9 @@ done: /* Fill out vectors at the end that don't need affinity */ for (; curvec < nvecs; curvec++) cpumask_copy(masks + curvec, irq_default_affinity); +outnodemsk: free_node_to_possible_cpumask(node_to_possible_cpumask); -out: +outcpumsk: free_cpumask_var(nmsk); return masks; }