From patchwork Thu Mar 3 12:39:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiaoke Wang X-Patchwork-Id: 547963 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15050C433EF for ; Thu, 3 Mar 2022 12:43:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbiCCMod (ORCPT ); Thu, 3 Mar 2022 07:44:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230456AbiCCMoc (ORCPT ); Thu, 3 Mar 2022 07:44:32 -0500 X-Greylist: delayed 197 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 03 Mar 2022 04:43:46 PST Received: from out162-62-57-252.mail.qq.com (out162-62-57-252.mail.qq.com [162.62.57.252]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DD71117C85 for ; Thu, 3 Mar 2022 04:43:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1646311422; bh=2mTqmg1W9dS0Kv/L7soH7R821Fj9eiYWYXJ3eGCvI9M=; h=From:To:Cc:Subject:Date; b=mlWvuDcfv4D5VP+9NYeqfBVBk/SDZPzjLBNIWZGVz4xwOKsTA5zQ02dIcSnKT6mas vYWbz0sSFUE5ONLlIM5RRqicWVSyJpSOx7qtOVQdVR3jcoXwmDMfsKq2E8GKqNwevk mNnY22ZZdlfIVeflR7stUnpvppLtIlCAHkNHzwho= Received: from localhost.localdomain ([218.197.153.188]) by newxmesmtplogicsvrszc9.qq.com (NewEsmtp) with SMTP id A153102B; Thu, 03 Mar 2022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ineering.com, peda@axentia.se Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup() Date: Thu, 3 Mar 2022 20:39:14 +0800 X-OQ-MSGID: <20220303123914.4469-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Xiaoke Wang devm_kstrdup() returns pointer to allocated string on success, NULL on failure. So it is better to check the return value of it. Signed-off-by: Xiaoke Wang --- drivers/i2c/muxes/i2c-demux-pinctrl.c | 4 ++++ 1 file changed, 4 insertions(+) -- diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c index 5365199..3203361 100644 --- a/drivers/i2c/muxes/i2c-demux-pinctrl.c +++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c @@ -243,6 +243,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev) props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL); props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL); + if (!props[i].name || !props[i].value) { + err = -ENOMEM; + goto err_rollback; + } props[i].length = 3; of_changeset_init(&priv->chan[i].chgset);