From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBBEC1ED38 for ; Tue, 25 Jul 2023 11:23:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AC40C433C9; Tue, 25 Jul 2023 11:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690284238; bh=xJ751Q5411hlh1GXLAsxvGJOQj+HPYp/0CALO3q7KCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EfSgxF6kC+Am5mm9BHziPhrnX/UUUIulA/Jlxz2Twc8bcXPLUuff6Fs7Vvhlz6P6a OoAHiaA0318kkOanJHgPDuxvRaez+4+RFTwZPpGdoYRyMnkPj7Qdxy1KCK6HFnj9GQ yzPoYAeiSPEBhn6uRpISmEq8Oy1bxvWub9ClFipk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Claudiu Beznea , Thierry Reding , Vinod Koul , Sasha Levin Subject: [PATCH 5.10 255/509] phy: tegra: xusb: check return value of devm_kzalloc() Date: Tue, 25 Jul 2023 12:43:14 +0200 Message-ID: <20230725104605.418639032@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230725104553.588743331@linuxfoundation.org> References: <20230725104553.588743331@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Claudiu Beznea [ Upstream commit 44faada0f38fc333d392af04c343b0e23f8f5d81 ] 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 Acked-by: Thierry Reding Link: https://lore.kernel.org/r/20230531073950.145339-1-claudiu.beznea@microchip.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- 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 f93be3c4a4a6e..8f11b293c48d1 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -663,6 +663,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.39.2