From patchwork Tue Jun 23 19:54:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223200 Return-Path: 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=-10.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 47D72C433E0 for ; Tue, 23 Jun 2020 21:19:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1C2022070E for ; Tue, 23 Jun 2020 21:19:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592947183; bh=7e30EfUiSxO/sFuvj8K/fgjGMIOHz30SAJcVZVXkjhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I1rC9mVE5yVNnr8QaQH7NUFEOSVl/XkKYXc+ddDsy5QThLLApEzhRDE+eS7NU3yRk GcXjK24I9RbM/Hha+Y7p/0ExgZS23TClAVxhvImUhksQvO5KrMXvCzAHpKquhSdJIx 1cAOtbRdEuhRcF59oCpLaOl0W2/64LRvcuabQ4Hc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390513AbgFWVTl (ORCPT ); Tue, 23 Jun 2020 17:19:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:43258 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389874AbgFWUYd (ORCPT ); Tue, 23 Jun 2020 16:24:33 -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 295962073E; Tue, 23 Jun 2020 20:24:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592943873; bh=7e30EfUiSxO/sFuvj8K/fgjGMIOHz30SAJcVZVXkjhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0X/cT2CLA9JWlyufgjrcU6ZK5EeTWj2Zr1tgez5B5FCSJOou00WWnCzyV6w7KQrhM hQR0aW+8xKbqlzTWa7hQVnNLDvbfbbHcD8rf9jeHzOXxh7Gflj11xT0MB3ArZiO49w IEkL42e9P8RWUsGIuFMG6f9D23xuy9zZJ/+sYm04= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chen Zhou , Rui Miguel Silva , Sasha Levin Subject: [PATCH 5.4 084/314] staging: greybus: fix a missing-check bug in gb_lights_light_config() Date: Tue, 23 Jun 2020 21:54:39 +0200 Message-Id: <20200623195342.876247014@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chen Zhou [ Upstream commit 9bb086e5ba9495ac150fbbcc5c8c2bccc06261dd ] In gb_lights_light_config(), 'light->name' is allocated by kstrndup(). It returns NULL when fails, add check for it. Signed-off-by: Chen Zhou Acked-by: Rui Miguel Silva Link: https://lore.kernel.org/r/20200401030017.100274-1-chenzhou10@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/greybus/light.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c index d6ba25f21d807..d2672b65c3f49 100644 --- a/drivers/staging/greybus/light.c +++ b/drivers/staging/greybus/light.c @@ -1026,7 +1026,8 @@ static int gb_lights_light_config(struct gb_lights *glights, u8 id) light->channels_count = conf.channel_count; light->name = kstrndup(conf.name, NAMES_MAX, GFP_KERNEL); - + if (!light->name) + return -ENOMEM; light->channels = kcalloc(light->channels_count, sizeof(struct gb_channel), GFP_KERNEL); if (!light->channels)