Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp520898rwd; Wed, 31 May 2023 01:25:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ECNYzcdezr/FiwzY/8NaO14XnZIAFVXNpjsqIZhAdUbJJZ3m7TafeXWNjDfVL/sJVtAmX X-Received: by 2002:a05:6a00:24c9:b0:64c:ecf7:f4a4 with SMTP id d9-20020a056a0024c900b0064cecf7f4a4mr6676488pfv.24.1685521531251; Wed, 31 May 2023 01:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685521531; cv=none; d=google.com; s=arc-20160816; b=TKkjKXPKW4eqxq0WxhnpKPV6ab9dmbXs+HEV4spMbNTdDPoeUK0T70FX17ZU+OGdD5 8uZoCdJXkZrYTyWhshqezEVlryw8pfu5XSwNvcdD2HWYVeaDyp6il5uQNrx2jGr2/YQq v7mlBrsbEqVSMuFC+I5oDIIkImwz5TFIpqXk0qcM3PdBjRodWnn4oFM0LexL2ifQu7ey JSN3mC/bgCrPG0iiwrJpTLjbGHqI/YFYgWI4As9lU2k2woRDfVginioEEgg9zOG9foT3 GZoguSPO8uk4LLWeOUSVVYYjt3LSBhs3Seap7xpi09gp3XhRSYOXruvSE0yiSxtgeFpN 5Frw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=xIsbWbszf08UhrHeL+QFDXE5I61fmqZht2huvemgzd0=; b=tw/1TnCRxqBtmXsL7x42l8OfuMpCdiGS5L6pizwR2IMlUpJVbx7t/W7f42xVmDJwrD mhZcYYafYctE6JfpSGnADr1dULa0M6ycQFGU7AU0H+2ko3nagSs+p6KLaq+CJY3DyvR7 Yy33I5MalUNKv+/vlzg52sOVDIukny3sjIM3Sxr7GTa0mfhPw4ohDyW0k3ErEr7X8xKS diRBOuang/0rhfuhpUpXzVvhFJA7wnopxONVHm7NaIQls2P/y9LmrgjJFZQslVOsEw8B CqbvXVADJoUmcRYtbeh6y8uPGFk6Mr64aHu4m2NSCPCIbooll11Qb4FZABai3ZKJPp7B AHDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=S9KKY9XZ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a22-20020a637f16000000b0050f6925a400si584355pgd.589.2023.05.31.01.25.18; Wed, 31 May 2023 01:25:31 -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=@microchip.com header.s=mchp header.b=S9KKY9XZ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234699AbjEaHkK (ORCPT + 99 others); Wed, 31 May 2023 03:40:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232464AbjEaHkJ (ORCPT ); Wed, 31 May 2023 03:40:09 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67125E5; Wed, 31 May 2023 00:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1685518807; x=1717054807; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=VA6PLEl6XdXdwvvyXjGG+l70IBfaxvdpG2t3qnCADZg=; b=S9KKY9XZvNV1hi7mWjg2E9LQb/UFY2CMGI789O6G6pNCw4cQxp5Pw3wB gXs/sXpTZNK9OGEe9dOWn0yNzFv3eR3JWG6C/BwKqweb8IYAyI0lffLGg XLjVhUUXvbdkau1S30OXo/UDDlmYIINKR+2RciTsy9MKSKXC8YYFX03YB SPZuWtkI8aJ4Pfidtb6IzSwWdNF83lOSXcwVN3Wv7/2938kJ+y8gphqT4 Zz4gCIr+0qH5GE/lB5qbyc5I87MNZN8nmwNEfYLndQ53MR1GcQEo8XxW9 IC224FeD8bIrtJXlmoz3eQsyxIXCltW7bcfVcW543/JdfxVP0Z46El90k A==; X-IronPort-AV: E=Sophos;i="6.00,205,1681196400"; d="scan'208";a="216163366" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 31 May 2023 00:40:06 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.85.143) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 31 May 2023 00:40:05 -0700 Received: from m18063-ThinkPad-T460p.mchp-main.com (10.10.115.15) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Wed, 31 May 2023 00:40:00 -0700 From: Claudiu Beznea To: , , , , , CC: , , , Claudiu Beznea Subject: [PATCH] phy: tegra: xusb: check return value of devm_kzalloc() Date: Wed, 31 May 2023 10:39:50 +0300 Message-ID: <20230531073950.145339-1-claudiu.beznea@microchip.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 devm_kzalloc() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script). Fixes: f67213cee2b3 ("phy: tegra: xusb: Add usb-role-switch support") Signed-off-by: Claudiu Beznea --- Hi, This has been addressed using kmerr.cocci script proposed for update at [1]. Thank you, Claudiu Beznea [1] https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/ drivers/phy/tegra/xusb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index ec335668563d..fe72bc74e7bc 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -675,6 +675,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port) port->dev.driver = devm_kzalloc(&port->dev, sizeof(struct device_driver), GFP_KERNEL); + if (!port->dev.driver) + return -ENOMEM; + port->dev.driver->owner = THIS_MODULE; port->usb_role_sw = usb_role_switch_register(&port->dev, -- 2.34.1