Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp122361ybi; Wed, 29 May 2019 17:59:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3k70hZW+ad/cAK8h1HSHvXjTYuKidpSXMmGhBlRK1wWMBIDplovX8m4IqU4vImjg21SEL X-Received: by 2002:a17:902:2d:: with SMTP id 42mr977457pla.34.1559177999573; Wed, 29 May 2019 17:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559177999; cv=none; d=google.com; s=arc-20160816; b=ZSwIDE81DbnuOD/ztOxyQnpH8H4PvEBzKETaY4n5GsiCqScA9WESxUpyBTVB2jUjrv oIUaXhadFLDKaJZK8OOH6cCSMxLvRHk6xaoRFaoBmNeTHxqLbcilj4LdOItgykx+Tq3C U+lFerBYnsAB9qa+qhA20hiV9tgRKDh7IP1WobcyAeIsTAZeFVWetG7IPpBAZoW6I5ae knqbkRt3H7p8ou1bCAiZW+pxRmCFBA7VGv43ME0OTOb7x4duAJc2jwyyl4OMaEbx6Uob eRy8wgsW0XWy5xJblNX6fCaJpP2DPdS2Y+JyoRXQFmxAoTs59/LUlZR8lDqKxoiSCRkm qWeQ== 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=+73xvdlcJ2eRJCM1UROZ+oXQ5VEB4CGineXnjJmLoCU=; b=OqJloianaxri1nTHMDw3Sqk6nQ5MElLvGIn1cz5Pgm1rv5e33iEFHGL98iJsTtgYNy XTXJIC7HU6e/NOztgeG7hg3zWIcZ6/CDQReo68fDjKqNNgsNkWyvXtSG5RI754VUW9ns /8y7MWB+iOUEOKzdSxR/kxXfm7OTo0NE8qZFcY9w5RCnKOd7ItWHRfGAr51yuJMZJ+Dn 0NEbSj6Vy4IKQztNfqK2zpewLML6ggaMPpw1C8fhhorcpKZM0Lr38lPjs+sUK0gZA8J+ 3uGLPuklYNQ+l1xsCWvwsiiymn360zHHF6odxBBWV1VuCU4hwoVf0DJspnmFdfa05dCx S+ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rR6DVP6i; 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 72si1391609plb.217.2019.05.29.17.59.43; Wed, 29 May 2019 17:59:59 -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=rR6DVP6i; 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 S1726973AbfE3A6i (ORCPT + 99 others); Wed, 29 May 2019 20:58:38 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:38534 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfE3A6i (ORCPT ); Wed, 29 May 2019 20:58:38 -0400 Received: by mail-pl1-f194.google.com with SMTP id f97so1802759plb.5 for ; Wed, 29 May 2019 17:58:38 -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=+73xvdlcJ2eRJCM1UROZ+oXQ5VEB4CGineXnjJmLoCU=; b=rR6DVP6iekA4Srk7Rc/isdvP+qxvJsUoGtrpYqRGyb91Nc7U1gGWmhu7cQP0uaz4tf Rzj3J1AILdzyLJuSQN9qSJTwrdc6ww8s161DFllflfKdms/JJuj/yLYhp0kpbcniI8MV FNN/p6wJ/ZzJg1tTeAvTIi7WROUBz+RHNd+8vU1o5N/VLF/6tcO1mA0dbMXxnAp641ut AKvubsGEhalc5JY459/1Layiq4LibuWFqrnv6GOti10fgIJu5V//+PS/lnkx1Fp6ZSJp kjqFKGxL2r+oJfrmLAAoyiwG7idmnGVHEqKghiAbtjHkxsvo7WFG4U/Ehl2NuBtjpBio C22Q== 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=+73xvdlcJ2eRJCM1UROZ+oXQ5VEB4CGineXnjJmLoCU=; b=UQJO7K24nWUsJEhvIsShBhGnol5oQy6c6JFO5/RQvLHja7+4W1pztNtTu0tkZ/gTQg G4vyabtYBRpmp46S7wD4x6mt7YkQ2B+TqxihuJjF9qSvLXTuJkUPPpfLFbgKVxbR90pC se2BSu5ioRVDsiRnksaHYSM5Adm2idsbh6CzoIAMoB518NOsnM5qAZChepmksgqNKhnH HM/MSFvnqmt1equ0+TcMoKqdmO1jJVWbN2cs2GPcYo954dkthbG0E9upQAJccI6acjxN eO+ZGrOWnv2Vbqt0mhjA5YX+f5mHrFNsONGn5r+OqcmOVzZWO4iKZ9zEinhGjzgKJfmK YjTw== X-Gm-Message-State: APjAAAUlyMAab6Y5zOOzPj4tFQKlH/t48ikEwRmZlfDRmwCO93qHILnP 73nQsbLNQqy/adYBfPWTRmV+f64QbhM= X-Received: by 2002:a17:902:9348:: with SMTP id g8mr957256plp.174.1559177917778; Wed, 29 May 2019 17:58:37 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id u3sm857766pfn.29.2019.05.29.17.58.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 17:58:37 -0700 (PDT) Date: Thu, 30 May 2019 08:58:22 +0800 From: Gen Zhang To: benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au Cc: 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: <20190530005822.GA5942@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 Acked-by: Nathan Lynch --- 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); ---