Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2247213ybi; Sat, 25 May 2019 19:45:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyZHYYeCsBNrNgpzAnets1PIeZ45xkJFZltXXQiM9+VKhp3WIyGP+0g0WDy0zL2Xv+46rFF X-Received: by 2002:a62:3145:: with SMTP id x66mr99746200pfx.223.1558838702737; Sat, 25 May 2019 19:45:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558838702; cv=none; d=google.com; s=arc-20160816; b=c4QSIZqmh18LQdp5KWFaPqN+bKjCp/3RS9ACIu320J42xIrBJX83FjaloPqMdbCdIT 97OkGHt7jv4e9Jg/DjCnlE1bQNs7so20gLgPTiNBChcc2YD0suucO0aqSNuNVEbX/mDH zSLwywja9jakN4B/QAWd3kyI4oYoMNyCJwkIBs0TNr5h8/db0TdgVo5GYJXVRyJydS5S sj2lbtTdrNLMv77Kts1gQ+w45ww0sK1MTwzFDg03IviGuAos/wtxamZXrOfhL1E1EeWb btnXNZEcpGy4KcCGJ82cxINyRlTmh1OSeoWNSc38W6Nq5pewwAcPZZtkCF3fI40TzW+T e53Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=RkwkVNo4DaOAeSezSEZu1BPpQiUJsVlAu63Y3Q0J0as=; b=V7yIcue/1XbiWsx6I82xiwkSj1HAqkjd/LwmMamTo3CWXB8tP6j9p3pexEBEyGhXiu AYYLJ2MDXAC95UgO1Ap+2Tz51h7q4wHkvRR5tdjMR7Swy3FPqykHiy9lqcsfYgbOpjMC +lnYPJawkKLkhpzgVp14DWYaywhCh08/RqNNCnTpp018nWPxrUj4mO4cpx3AOP026mO7 N4cvHw1lUKrK2IRy4400wmXGnpR0WowDKNDPFLbiqLrACEwu/yseUGoqPt5MKTabfzpM uRKZDj5PMRyTmCkeYjLjm2Cm+He1q+E72BdbV8veeGVoJKXhRv/azLSdUs2BZO5nnUHv EWIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VFapM4S6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 140si11931216pfx.198.2019.05.25.19.44.35; Sat, 25 May 2019 19:45:02 -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=@gmail.com header.s=20161025 header.b=VFapM4S6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727581AbfEZCmw (ORCPT + 99 others); Sat, 25 May 2019 22:42:52 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:34627 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727481AbfEZCmw (ORCPT ); Sat, 25 May 2019 22:42:52 -0400 Received: by mail-pf1-f196.google.com with SMTP id n19so7578898pfa.1 for ; Sat, 25 May 2019 19:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=RkwkVNo4DaOAeSezSEZu1BPpQiUJsVlAu63Y3Q0J0as=; b=VFapM4S61GN+qB2G5Awgz4EuZ7yRQpW5xmyqY4EJy7hgZoOhboT6a+qHK2PqxWCkPL 15ScBNmaZczxsVO7e/1c/O8157kJf7c92iQ/OqMSa8nhIBDY83MpZ0Ki8V9hsjWm3Y7v npbBYYyr5TXyszywUTBOjvyfEZAwVoXy3f2SEyfm4e8a2jbCEfu/qHiw7wRFnEpTEaYq zgiOTzbBMglOZpVMB8HECsv1kJLFGama3c33LH/ik4ZF0HfUzSX4cSAoETRuSnYqwFQb nUcwvSC1VuaB12z/gvbu/rG/UavbB2tDo/xCdpDmsfvScfii2ye+BDlVO4Ayx0qGOW4N uLng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=RkwkVNo4DaOAeSezSEZu1BPpQiUJsVlAu63Y3Q0J0as=; b=c5Pw0LMSx5nqhhdVlEdg6e/Tv48LeCfWQFLdhi/0+TCB5ocjFt6NkNFbtxJ7MjVHOV CgqOnmvmN5ZY/dqjGfMWWwXVLq7+4hEda12i9EPDzqKm7ubLun1vZ99WWZ4DBUzyFQ0N TUQ4BMKzSkOqBJfQJcxAW6wZq/kMIJzJhz1fT/yp0eGmTfaggM/lcp25bqH2a4TsTFql iGu4aLxpNFJ/Ra9dm4ricQ2PPT2Dxspn96KXVfUcPi9lg8YTu93ayiIlBAL68K/AG43L hTQ4wUvEAO5Y07IBROZTGCgLBSD/TvVL6hLINFyjxTaFgS8B0DY5Q7NMG2/FeBNz2Wtc 5knQ== X-Gm-Message-State: APjAAAU8LnDNHHpH8Da1mQrWw6+j5cK/cBJxD45AH63rmQOlMxdH8/gG XCGizjQkZXlky7m896ikmUWiOq2S2qfChw== X-Received: by 2002:a17:90a:35c8:: with SMTP id r66mr20779605pjb.17.1558838571495; Sat, 25 May 2019 19:42:51 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id x16sm6526480pff.30.2019.05.25.19.42.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 May 2019 19:42:51 -0700 (PDT) Date: Sun, 26 May 2019 10:42:40 +0800 From: Gen Zhang To: benh@kernel.crashing.org, paulus@samba.org Cc: nfont@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] dlpar: Fix a missing-check bug in dlpar_parse_cc_property() Message-ID: <20190526024240.GA14546@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In dlpar_parse_cc_property(), 'prop->name' is allocated by kstrdup(). kstrdup() may return NULL, so it should be checked and handle error. And prop should be freed if 'prop->name' is NULL. Signed-off-by: Gen Zhang --- diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index 1795804..c852024 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c @@ -61,6 +61,10 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa) name = (char *)ccwa + be32_to_cpu(ccwa->name_offset); prop->name = kstrdup(name, GFP_KERNEL); + if (!prop->name) { + dlpar_free_cc_property(prop); + return NULL; + } prop->length = be32_to_cpu(ccwa->prop_length); value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset); ---