Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5919631pxb; Mon, 14 Feb 2022 10:41:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJyTxfRGgDEde1U7z+ENNz7BWWIDJVihkBjEd7629ltSaNh51yPoZ5zirsIXBOEORSauWrLR X-Received: by 2002:a17:903:1210:: with SMTP id l16mr124824plh.63.1644864068076; Mon, 14 Feb 2022 10:41:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644864068; cv=none; d=google.com; s=arc-20160816; b=wTIVDiBwLv0xiiE9cLga6CogCN+JfE7pYsWHc+8u9ptgLn4+2QTSA1D51smoQkw+03 OaAko3uGX+8y1B/0QJxK6tyr5r5sAKFT1wlIaPSmTXeHy3Wh+2H8gBDTwEoDCUcvShzh 6N+TFiqnq+Y/SNSzLt/3SujFJnwEJ69BoJnpa1XmVnQ/RePeHe9B/pNMC5x2CbyTEcCy YXkhjavWEc9QLe3YY/smQAZNpz7mzj/fTm0eT24BzJJeTFJRuSnqKK0FQItJ02TbNyc2 qJ4sORdVGEJdPSvSkw5u+7q4SAc4BE7XDeLj0L73J56P4vcxxlKBkeNBYJo1Wd/9F4YS O8XQ== 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=yBuAMLN4pLpf9FruLpNggjInwGntllbDCJHviAWFzoY=; b=n8AvC6Xy0kimX0aEGig8/BLUORvpZxxFemT0BrWlco9kYgLRdY7D8067p9T8cGFN24 zlEplvsSPNWB6L9A/KZf3TjfgtftuZ8TmMAEbKCbMepQLFa5kazDbLEszOBZ7FDE1TaN 7OUGX4wBVcsKBgyzicX+gJX99K59ce3mG+dKDvYexZ/FdeNW98iNmP1HV5WiN/2p8bck 0MnsjTfxH65ld3FZocrlPipmOPUudxuvmpmEzUrB9LR6EwHOJrAYsYnkIrkGkre53IbY QyQsS1aAq1i0t0F8QEBLdEpib8kJ5YhBhCQ55xJ4g8f1UJHRSXmgTOVwdW7lAtBgUHGo 3+bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ODMtmNRt; 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 bj23si444595pgb.127.2022.02.14.10.41.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 10:41:08 -0800 (PST) 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=ODMtmNRt; 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 623C566222; Mon, 14 Feb 2022 10:41:02 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245323AbiBNJs6 (ORCPT + 99 others); Mon, 14 Feb 2022 04:48:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:43378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245742AbiBNJqI (ORCPT ); Mon, 14 Feb 2022 04:46:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1F6E69286; Mon, 14 Feb 2022 01:39:36 -0800 (PST) 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 dfw.source.kernel.org (Postfix) with ESMTPS id 609AE60FA2; Mon, 14 Feb 2022 09:39:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 08132C340E9; Mon, 14 Feb 2022 09:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831575; bh=JJpFLpXzXPk/tob/exmxLZtN9BW2CT29sd98rwJznw8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODMtmNRt6O6mMqMO/36byp1+vb4I5dCRFTEbOFuSVTWpFzUUPOy+r4V5kSmYamxwJ q8tdeQxl8pcebTobtJEheyqm38vcwTkA3p2ynSShX1vhPo7fLinq9XuBwD9U5gZExJ Q1W5th4QJJE9PmClLs+pjwb05tFkRpiHNaDmjgwk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bean Huo , Xiaoke Wang , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 026/116] scsi: ufs: ufshcd-pltfrm: Check the return value of devm_kstrdup() Date: Mon, 14 Feb 2022 10:25:25 +0100 Message-Id: <20220214092459.584903113@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092458.668376521@linuxfoundation.org> References: <20220214092458.668376521@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: Xiaoke Wang [ Upstream commit a65b32748f4566f986ba2495a8236c141fa42a26 ] devm_kstrdup() returns pointer to allocated string on success, NULL on failure. So it is better to check the return value of it. Link: https://lore.kernel.org/r/tencent_4257E15D4A94FF9020DDCC4BB9B21C041408@qq.com Reviewed-by: Bean Huo Signed-off-by: Xiaoke Wang Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd-pltfrm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index e49505534d498..0f2430fb398db 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -92,6 +92,11 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba) clki->min_freq = clkfreq[i]; clki->max_freq = clkfreq[i+1]; clki->name = devm_kstrdup(dev, name, GFP_KERNEL); + if (!clki->name) { + ret = -ENOMEM; + goto out; + } + if (!strcmp(name, "ref_clk")) clki->keep_link_active = true; dev_dbg(dev, "%s: min %u max %u name %s\n", "freq-table-hz", @@ -128,6 +133,8 @@ static int ufshcd_populate_vreg(struct device *dev, const char *name, return -ENOMEM; vreg->name = devm_kstrdup(dev, name, GFP_KERNEL); + if (!vreg->name) + return -ENOMEM; snprintf(prop_name, MAX_PROP_SIZE, "%s-max-microamp", name); if (of_property_read_u32(np, prop_name, &vreg->max_uA)) { -- 2.34.1