Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp269453ybi; Wed, 29 May 2019 21:03:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxT+UcDc2btfOoGFiCGwWH40ipTIBNEkhqufyR5ZHiZJUeg6zYDLlW+4vmE8zXJTyz7gNPN X-Received: by 2002:a63:d716:: with SMTP id d22mr1818461pgg.244.1559189014765; Wed, 29 May 2019 21:03:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189014; cv=none; d=google.com; s=arc-20160816; b=UxhtRmZMWJ8w/gEzZpyUXyI3H5OajxsV3WQNPperBZd0u7YUm7dODbwnpowOwM7MPV WG1Cc8FqDvyPZOZJxNOOQmfiW88qXuhVi6J6LSMZJnOQ+VPe/d/X7l4KduzKXfqSE2hK jpNPT9VKUGvk1FNF40VLZwfIlUi+oTRZcXC1gysZUiPCJbmzfe7W0MvtUDFsfSwJGuub QNxgo9XjIX7sGufKtAR+q/dqPgwK+9APdQj6DoLVgLckmCdte31I6787pzTaVFzFAXvs UQB/jcFA+XF3y8SPy0AlQpZ0BRLG0koTvBE68mzgQPKztMB/I63UxAx+aaB7cI5s5+HE wykQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+zVJuKHgaGE9ZcDN0b/lFK9gPGEMnYDHEOuslHn7BBM=; b=LV/Q+G8JLl4Z+a4LlJaG6TiEzpZ9vrwXAirFApcNw7V7CKad+Q4njcpPS9gEU3FOgS ylm5z9SZtK4kiMwcMmd922rkmptzZUsdTwdnLB7lfHFvErrLQMeAfLiA+Yfh5rfHZS96 W1sho8eZALrADWKqLOCyIIIDJEu3HB3jYQDJlfxJ6xib0sTC1dTLZgmVpU0VoMJ3M9Tw FH9lVk84z6mrwC6/BQjRua+XIWGbKBMslr5Y15BrE8QmWjoMtIMhbEU0/lV9skKXVFh7 SL4MhudmxkCiLRCQmYaFxQUd43CngwUJ2ojp/UJRu29p/VnfflAshZHl0+WODDxly0gW GIVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hPA8k5a0; 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 m19si1931139pgb.427.2019.05.29.21.03.17; Wed, 29 May 2019 21:03:34 -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=hPA8k5a0; 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 S1731813AbfE3EBI (ORCPT + 99 others); Thu, 30 May 2019 00:01:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:50346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731463AbfE3DSM (ORCPT ); Wed, 29 May 2019 23:18:12 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 652FC2475A; Thu, 30 May 2019 03:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186292; bh=40Dw/r2+ge0n1REOJJdhybpmlif7X0HbTBKF0F7o8gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hPA8k5a0+IkhRklimmDSYX4j4E9/TvGtYeEd2yxlf5yHz+yBJGjWYZQZi/Ora1LY0 TQSEWL2WgXIW1KzdQoqe6LqAURXmx2cSxz5Bj3VhO3wS+FlVzyDSUU4MyuG1Hb5c3r Zxg5I9HN+dSX4xvIvDy3ccfazqBkDjeh7qKrMKD8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Mukesh Ojha , Mika Westerberg , Sasha Levin Subject: [PATCH 4.19 224/276] thunderbolt: property: Fix a missing check of kzalloc Date: Wed, 29 May 2019 20:06:22 -0700 Message-Id: <20190530030539.120474383@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 6183d5a51866f3acdeeb66b75e87d44025b01a55 ] No check is enforced for the return value of kzalloc, which may lead to NULL-pointer dereference. The patch fixes this issue. Signed-off-by: Kangjie Lu Reviewed-by: Mukesh Ojha Signed-off-by: Mika Westerberg Signed-off-by: Sasha Levin --- drivers/thunderbolt/property.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/thunderbolt/property.c b/drivers/thunderbolt/property.c index 8fe913a95b4ad..67fd0b5551ded 100644 --- a/drivers/thunderbolt/property.c +++ b/drivers/thunderbolt/property.c @@ -581,7 +581,12 @@ int tb_property_add_text(struct tb_property_dir *parent, const char *key, return -ENOMEM; property->length = size / 4; - property->value.data = kzalloc(size, GFP_KERNEL); + property->value.text = kzalloc(size, GFP_KERNEL); + if (!property->value.text) { + kfree(property); + return -ENOMEM; + } + strcpy(property->value.text, text); list_add_tail(&property->list, &parent->properties); -- 2.20.1