Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1197824imi; Fri, 22 Jul 2022 20:56:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u/yHr7OTnrb2Wa5XXfXe1czeWl+FhhUV7hSFhGdtq0LgJ97cAEVz+LoH1bTZRpKph+lXA4 X-Received: by 2002:a17:90a:b781:b0:1f1:fd70:e366 with SMTP id m1-20020a17090ab78100b001f1fd70e366mr3088291pjr.184.1658548560331; Fri, 22 Jul 2022 20:56:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658548560; cv=none; d=google.com; s=arc-20160816; b=mMLzHq7Of3EaDlcIFw6nAJ07NFAnWZuXPem7ns+GJDNGMaYLoKjkB+DfVT1AcDTbn1 gql1V45L/mlB1sX0RhbVL+lVB5YgjnOSPp2Xf71zq4QoyA7a7Ni6ibP+XKn8ghjfPfKj Sv3nSny2LEPqDoaS6zcWr42vdrLUjl9YH2Cx96ce7qIsnvKAmbHVk1kKwt05/Ek4hRqq klY0nsO0q9UbO51fDMTfEaJg1n3McVYhpNjJh7HNOnqMNjN2lLex+tRT+QPYvn8C8Btu PpOICzegPuS75JnU2k+Ok/rFYUfvmmpM/luvatxl9cEhd4pcPQ+XONeezJoHM+R3AUqU M8Zg== 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=E5bSd3wPwM3u95WU8fODTOt0SYOO2PuBYzObYqAQDrI=; b=nxOKsFledBPZwmQeFpG2NxMuItdfaRAG0dfsou3usqzgjLdshQVGW3kZpQuVpU7rdc cM6uecbULzfXKeMZVmGq5uSGTHcVbW15K15okr5mYHzWpg4tQxFWsYZJS6giS1DknZec F1/Xg0YtDOqkRZpovaY10o46sS1HbEorvASG3NlY1spqFIRVv+9Ch+J38Oc+ocGPzir+ xQxCZYp3vdrgQXG58uhSItlh9ihBG1QucSEYJzaH3kYFxMwR1HG/lMTBmVNlShY0x/zv JpZf1VT97qi3w/RBR5BDwC7+joBtkgteIi1lhXoAM6Kr4jWH0lZyodgktmjKQJvBxQjX MSWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=iRv+6pW8; 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=163.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a631308000000b0040de79f8b78si2284998pgl.500.2022.07.22.20.55.37; Fri, 22 Jul 2022 20:56:00 -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=@163.com header.s=s110527 header.b=iRv+6pW8; 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=163.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbiGWDmi (ORCPT + 99 others); Fri, 22 Jul 2022 23:42:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbiGWDmg (ORCPT ); Fri, 22 Jul 2022 23:42:36 -0400 Received: from mail-m972.mail.163.com (mail-m972.mail.163.com [123.126.97.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2EE6B71BD0; Fri, 22 Jul 2022 20:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=E5bSd 3wPwM3u95WU8fODTOt0SYOO2PuBYzObYqAQDrI=; b=iRv+6pW8Hr3VHiGikm4HG R+lmJR6UlD6EMcerIkQENZMupg+rll2pmRbQfTP6sjOlPGaAVMn7DeuBgoSiSh4s SZT9E0WQnB2POkS2luRvVTbFtgJWD3spN3dNCoTgGw3XQ7W/6HGRTucBaEpUV+Ol s3u8lmdK/WvELVbGrOan7Q= Received: from localhost.localdomain (unknown [123.58.221.99]) by smtp2 (Coremail) with SMTP id GtxpCgD3sQvrbdtiiq_7Qg--.36884S2; Sat, 23 Jul 2022 11:41:33 +0800 (CST) From: williamsukatube@163.com To: linux-phy@lists.infradead.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jckuo@nvidia.com, kishon@ti.com, vkoul@kernel.org, thierry.reding@gmail.com, jonathanh@nvidia.com, William Dean , Hacash Robot Subject: [PATCH] phy: tegra: xusb: check the return value of devm_kzalloc() in tegra_xusb_setup_usb_role_switch() Date: Sat, 23 Jul 2022 11:41:30 +0800 Message-Id: <20220723034130.2952016-1-williamsukatube@163.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: GtxpCgD3sQvrbdtiiq_7Qg--.36884S2 X-Coremail-Antispam: 1Uf129KBjvdXoWrtFWrZrWftw17Cw1kKw1ftFb_yoWDXrg_uw s5Zr97Xw4qgFy7Cw1jyrsxZrWSyrW0qF1IgFsYqFy3CrW09F40yrWDZFy3u3yxC3Z5GFZr G34kZF1Fvr13GjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU5tsqJUUUUU== X-Originating-IP: [123.58.221.99] X-CM-SenderInfo: xzlozx5dpv3yxdwxuvi6rwjhhfrp/xtbBew1Hg2AZAZahXgAAsj X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 From: William Dean The function devm_kzalloc() in tegra_xusb_setup_usb_role_switch() can fail, so its return value should be checked. Fixes: f67213cee2b35 ("phy: tegra: xusb: Add usb-role-switch support") Reported-by: Hacash Robot Signed-off-by: William Dean --- drivers/phy/tegra/xusb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/tegra/xusb.c b/drivers/phy/tegra/xusb.c index aa5237eacd29..e3611fb4c779 100644 --- a/drivers/phy/tegra/xusb.c +++ b/drivers/phy/tegra/xusb.c @@ -668,6 +668,8 @@ 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.25.1