Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp600122pxb; Tue, 5 Apr 2022 15:30:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3u2x7zBGkkYkq2b/n/sg648M6jdU/foOH/zNXyHnU7L0hoPYDO7tioFe+rvEXTwcjtKMH X-Received: by 2002:a17:90a:2f8e:b0:1ca:aefb:c796 with SMTP id t14-20020a17090a2f8e00b001caaefbc796mr6552750pjd.66.1649197850099; Tue, 05 Apr 2022 15:30:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649197850; cv=none; d=google.com; s=arc-20160816; b=k7HNtDJEWY+Jcon6RhZP2gpM5y9Slb267dJvVV6OkROKKLGJWKhR5+V9vhU38AQEvX 00yTmwKfNCRUvG9Z48qPfS5Pw4gtTYD/Ek3cEFSv7VDDLOdA+ZvzsYT2d85EKnzPnk4D V2auUCY0soDbKgx3a0mEJxOMkTwPPoF16Bunl6FIeXqDgulEV7nlCuluojdM7nOPC4nw 42sJUKEDJcWZG5ws+FFghW2hPWtKMb2P2+TsVl/yfOWAgTAwFHfe1+fr+e1nawi+fLo3 8l4Uxa6gR1WbmA5DhSgzFEywVjfJo444UN/paiEaoPtsSX7Hjq/ktKcOseNIVCaHxqaD svdw== 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=9Ze6GMvT9HocIl/u8eVEIJtaBWemP1MBC3ms2sG7UJw=; b=iaKUB9zWoROC85V34Pvi0gWAtNzuuPKCKKKIy5r0yUt4vJgX97zNdmwp/NUnfNPK3v 1S+V3yBHlL62UQfdjm58QGM1CRDG3i9L1SgIVXFjwO4xmVWFFkmxABL3tRGp9trweVsu OF67GYnG6m3gysc1u/OxlJCsGcingRj+GbdojLSlKYl7mSMBddBxeXXWRf/mxTbTB44P qjPi9sv4KHz16Qx7Bge3qPxKU9z9stJ+8YupdoYa1h2dcg4z6UbIGIIoQIgXj0TXffFY 1Fp6mT/2O+0K9Zu1YfLd/Ps5qS/fuKV1zt0+6P9Lh8sSMt74I5Rav7cEy0rvRM56AOKf ycvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cuNqEP+8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g17-20020a056a0023d100b004fa3f687674si14732962pfc.256.2022.04.05.15.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:30:50 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cuNqEP+8; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4645A205BDE; Tue, 5 Apr 2022 15:12:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344993AbiDEOzL (ORCPT + 99 others); Tue, 5 Apr 2022 10:55:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343696AbiDEJlr (ORCPT ); Tue, 5 Apr 2022 05:41:47 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DC82BD2F5; Tue, 5 Apr 2022 02:27:21 -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 3167AB81CB1; Tue, 5 Apr 2022 09:27:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85103C385B1; Tue, 5 Apr 2022 09:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150838; bh=Qu8MHTsIc7m023b0AUDv6WD8HQbm7Xu0XOgmCZuC4Xg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cuNqEP+8tFDnlwFSTmLgV86sNij+DWgzN4QPgiLiUUF1Hdb986hnnkfJMyN8bEFH7 +DmcqBLJxqWGx2J0UkmmDv6+SFDuvK/qQsaJagZBc9GyLAYm0ttnLqz3c1ec6uMdm/ wVk5P4cJiLS79fYmfJjyFXDd0qX3EE6xraKFft3w= 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.15 199/913] thermal: int340x: Check for NULL after calling kmemdup() Date: Tue, 5 Apr 2022 09:21:01 +0200 Message-Id: <20220405070345.823703273@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 176b8e5d2124..258f56eba859 100644 --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c @@ -469,6 +469,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