Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp663800pxb; Tue, 5 Apr 2022 17:51:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6J1P1GNUiz8SGCJSOvBGeFzRiLykby9e0rIFRBUHQjvGS+SAxuJCqtXu72FRS/p4DmyNn X-Received: by 2002:a17:906:cf99:b0:6e7:9ff0:38d9 with SMTP id um25-20020a170906cf9900b006e79ff038d9mr6064319ejb.646.1649206306574; Tue, 05 Apr 2022 17:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206306; cv=none; d=google.com; s=arc-20160816; b=rxCh8A04IWMIzhwNiA8fDR5Ss0iIlrPQcm2e4AkLiXYoO7PiS1fjA1I/rjVFXMAcjY 1XKfZtcWDu4hHtYtptlntOOZWwvpf7aE8gBnKumW7uI4M5iKYIEn8oWg8s4yRhC+Rmy5 zyjTJEhCOgq0KHLr+Jo0ju/QR5f1FfuE/W8No65ddHCWP59BdxWrMgwzfnL89gNWsjaH qvzqH44bollkrKbjGQlZPOv6eHAJ15w9gcU8rEhG4DHYoxIb2J/q3AcdfxZ7bQMz0uUz 84W4z+WgaOtIIU1+Db5xVraKJqa5vMJk+DDOGxn/2twedOAKYyo5Mhk+wKfst57g4Tv7 9tgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rNTy41gUKbezmB5/E5dW/at9SRZMFUt7q86MF+L7+Nw=; b=Egn95LQDOmMZCLOOMwsXLIv9pwkVKDs74Ji0kYtFaYOLQdwwZDhwYXvpA8VkOi5fGw 1tQgnCHTgOxR+gx3nwc6CWFnfF+spyoKRJg8lUhfKY1ODrTexmMOZO5FA99THJVwEUOp PYcDZKgXmeJI43IVhJ7Xx5diEia6902jvFG+X7SUqD7OiYachKam1jFBRNugm17blWpv +QkPtfsK5UTvSVM0weAFrm6lh86P1GrR8CWsbQ7P1JsRu9Ah/a4UGeDebbN88N2a5Kbq 522Xc0Nm4S6hYOaiNKuZupRZ8tioUmxS1RNKP9O7RU/IR7Xh/3EoEBT7GWc0LtY8gX7L wFLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uah0iEzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g20-20020a170906c19400b006df76385ee7si10365141ejz.903.2022.04.05.17.51.21; Tue, 05 Apr 2022 17:51:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Uah0iEzb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378228AbiDELcQ (ORCPT + 99 others); Tue, 5 Apr 2022 07:32:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244433AbiDEIwG (ORCPT ); Tue, 5 Apr 2022 04:52:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A832AD5E9A; Tue, 5 Apr 2022 01:41:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CBA1FB81C15; Tue, 5 Apr 2022 08:40:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3CF6CC385A1; Tue, 5 Apr 2022 08:40:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148033; bh=mosdTcOT6RSLCeVL6avH9J0yKmMDzV2xBu0IjWr+Kk8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uah0iEzbLFDgQNs8NFbmWv0SmQOEdCqkhbKO5ZRMWQESkhlKxjX4dVCUm1dcHgyvP 94hF0okC9sYqHy6ho9r7zhC01a8tOPqRrq05vzEyr7rCUcrlmA26iL+PLqq+d3mGWa nkA5tqNGs3AKRPHxz55YMLWlprNIpREu6a2uD0eY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.16 0210/1017] thermal: int340x: Check for NULL after calling kmemdup() Date: Tue, 5 Apr 2022 09:18:43 +0200 Message-Id: <20220405070400.484742119@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiasheng Jiang [ Upstream commit 38b16d6cfe54c820848bcfc999bc5e8a7da1cefb ] As the potential failure of the allocation, kmemdup() may return NULL. Then, 'bin_attr_data_vault.private' will be NULL, but 'bin_attr_data_vault.size' is not 0, which is not consistent. Therefore, it is better to check the return value of kmemdup() to avoid the confusion. Fixes: 0ba13c763aac ("thermal/int340x_thermal: Export GDDV") Signed-off-by: Jiasheng Jiang [ rjw: Subject and changelog edits ] Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c index 68f61a738930..7ec2d6c7fe42 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -468,6 +468,11 @@ static void int3400_setup_gddv(struct int3400_thermal_priv *priv) priv->data_vault = kmemdup(obj->package.elements[0].buffer.pointer, obj->package.elements[0].buffer.length, GFP_KERNEL); + if (!priv->data_vault) { + kfree(buffer.pointer); + return; + } + bin_attr_data_vault.private = priv->data_vault; bin_attr_data_vault.size = obj->package.elements[0].buffer.length; kfree(buffer.pointer); -- 2.34.1