Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp52052pxm; Tue, 22 Feb 2022 06:14:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrXQkzsWjxQoxPrN8iqDUSM/yU5dRFuUgbsZZoRcGOoPBU4wpgGRpqwkPBu/qTNZIv/Fr+ X-Received: by 2002:a17:906:aed4:b0:6ba:6d27:ac7 with SMTP id me20-20020a170906aed400b006ba6d270ac7mr19883028ejb.33.1645539240696; Tue, 22 Feb 2022 06:14:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645539240; cv=none; d=google.com; s=arc-20160816; b=eA0VnZ0U1Fd+0MHnjLsM0S9OEFbJ2/G4HBd10jRFZ8egnx0P5oHbmpVyukWWWeQmOc rxATKITSee+Q9Uwn4Dt/lPw1u4K3lsxNqlNn+yCammEVb0EnaDf8rLZvBt86nV4mwz1c ZH7DWp/FX8D7wmHnqAMqa50vZysOf7Muvy45QkJYYyYZcYS/yicPlk2Z2XXt1ZJOs/+6 QIekQ7VhzDvceGjgwjTCzEM9y+TZFmGOicohUFt5ci954qiomzvfwDQ4jkLAkly05N9l WhbOhdJSLR1sALlk4zV5qieo3jHGkts2kbZi1ancOjCY4kb50u9RXGotdgIgYRWoWU6X NlvA== 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:date :subject:cc:to:from:message-id:dkim-signature; bh=5Rr06d3Yrk3kLF8gXcrflHOop0uoK/3urOWvnEtWmH4=; b=VvcahLcuSN4mx/LqXQwF7+SJCW6ZCk8GeYMJ/dlgRPptpbrOyWlmZzyaAAD9/2XGv3 sDfi3/1uFGIPk3NzSH+hDn3mO4TNJjq9QSP5Ld6mWokmW1fdboEj8SOu1vh1rvBB0V9r Q/AIq5d35+oZ37Qaw1i2c3SdBNOhb+cx7/gzKOViNZWAHOg9K2WQ4r88i0rsLWk/re2W DvSq0gJxJldfL9s/2rPYeguYgbrYsYlXGi1w+2KnUi3M238FD1egxOJre+29Mz0N8q6X AYsLQvwXZ9EIQWDJTF5hZRsgDkOScXcSRpz0YpjUu0okg/SN/PZeEkNSq6eXZI2vK4D3 3lNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foxmail.com header.s=s201512 header.b=wom2MThn; 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=foxmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fj1si12106161ejc.948.2022.02.22.06.13.38; Tue, 22 Feb 2022 06:14:00 -0800 (PST) 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=@foxmail.com header.s=s201512 header.b=wom2MThn; 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=foxmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbiBVLyi (ORCPT + 99 others); Tue, 22 Feb 2022 06:54:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbiBVLyf (ORCPT ); Tue, 22 Feb 2022 06:54:35 -0500 Received: from out203-205-251-73.mail.qq.com (out203-205-251-73.mail.qq.com [203.205.251.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907EC11476F for ; Tue, 22 Feb 2022 03:54:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1645530845; bh=5Rr06d3Yrk3kLF8gXcrflHOop0uoK/3urOWvnEtWmH4=; h=From:To:Cc:Subject:Date; b=wom2MThnW5HiF1vkfswGwEK+O/3fYEULtzLy4T+FcYODeqDZXCuIwtRYwNKhcYE2y cXmKRwntBz6WQdgQFfx4WtavIrIZ9W1UdzUz8aEFJe8cVzvdLK6FnVTKlX4NLQUdPd CDwnEX+SPmDIsIJFuPDqWClx6pGJngbACN2ijIqg= Received: from localhost.localdomain ([218.197.153.188]) by newxmesmtplogicsvrsza7.qq.com (NewEsmtp) with SMTP id D828323E; Tue, 22 Feb 2022 19:54:02 +0800 X-QQ-mid: xmsmtpt1645530842thq7la2s8 Message-ID: X-QQ-XMAILINFO: NO7nxmS7l766leqfrpUZ5sDiiO2Ci+eePA+fHyfgbhMFEv3iJBETm3aqlE5TeR k+vLbLRC0hPGfKZLatOPMfn83VBHBl0Crmu/Xwx/QzxAYxtqLCSFJnpdSGDAXy47GKgA3CmNPSTR jWDwQGvJXJodVs4cCc5lSwoaWwn66NXtHZkL/2dDmHaXMfS+5QeVbnkNIu9Qr1fALG/20oefUhXY LcJeFwX5x0U0TwExSqzaP9K7J7rhZJelir2YEf3wPxIv+PZan+RvMXc6XcspHQBV+GyXslg5B35/ oFlz64F3CxpaprsuTZzgpAr3z1vsh9oqjJWk7sUNzGTO5iofsodVn86MXw/w9Y/+nbVANdKkGr5/ aJSv23JTq9wtwPiw4Vj3TCmlnLrQdJx+SKoJwvwb3aPbak55Uu9kGlIR24p+AFVSikYAFCNzRvce 4xu2n5XHxjjFTAqcKOUOOiv9FDysjcVVSFL7EUIxvyzvVLu7ZoUp2GMS24kSi6Wy93KviJItfOYE Z+O9t1kiXVxydSbLzyOUWly8jzHNHT26Yifdb+UVPVfUpjS9t6D2670A17Hyr7GeZTaaHLzsduyk r336mDqgZJnOBrlU8W6he9+zhp0CMjtkbudzyo87cRsBwBfNu8BIaDmSNyW3fyNk4R5sdRsPBXAn FUTqHyotwoEvoRqdSafpX7wVn3JlDfwIBjboRSVlHrVUzqhtwEyw2SeDp8To8s91LmECDlI5NqTy qPignu+D4kAzsbSiS0ziCzooKrKv27aaU+MMsLZNjiaPjLbX2dxbZ2Y1+uKuDb+9Du+HF8ADa/gX Z4+PvR+N7YMnRc15TVDzLp1wzhiCJwa3XWoRpwkxzr4Mke4wX7qruA3Zpb5X6mNjzG8IKcMs3dFN C9UYJ815cC95aRU9mXnSMXJO6kHBw/xsMcC3tVY0sMmCECxYpABfs= From: xkernel.wang@foxmail.com To: tiwai@suse.com, perex@perex.cz Cc: krzysztof.kozlowski@canonical.com, s.nawrocki@samsung.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Xiaoke Wang Subject: [PATCH] ASoC: samsung: i2s: check the return value of kstrdup() Date: Tue, 22 Feb 2022 19:53:32 +0800 X-OQ-MSGID: <20220222115332.4084-1-xkernel.wang@foxmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, HELO_DYNAMIC_IPADDR,RCVD_IN_DNSWL_NONE,RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS,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 kstrdup() is a memory allocation function which can return NULL when some internal memory errors happen. It is better to check the return value of it to catch the error in time. Signed-off-by: Xiaoke Wang --- sound/soc/samsung/i2s.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 309badc..70c8271 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@ -1349,6 +1349,10 @@ static int i2s_create_secondary_device(struct samsung_i2s_priv *priv) return -ENOMEM; pdev_sec->driver_override = kstrdup("samsung-i2s", GFP_KERNEL); + if (!pdev_sec->driver_override) { + platform_device_put(pdev_sec); + return -ENOMEM; + } ret = platform_device_add(pdev_sec); if (ret < 0) { --