From: Xin Ji <xji@analogixsemi.com>
To: Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Xin Ji <xji@analogixsemi.com>
Cc: bliang@analogixsemi.com, qwen@analogixsemi.com,
jli@analogixsemi.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] usb: typec: anx7411: fix passing a valid pointer to 'PTR_ERR'
Date: Fri, 22 Jul 2022 16:18:35 +0800 [thread overview]
Message-ID: <20220722081836.3380885-2-xji@analogixsemi.com> (raw)
In-Reply-To: <20220722081836.3380885-1-xji@analogixsemi.com>
Fix anx7411_typec_register_altmode() warn: passing a valid pointer to
'PTR_ERR'.
Fixes: fe6d8a9c8e64 ("usb: typec: anx7411: Add Analogix PD ANX7411 support")
Signed-off-by: Xin Ji <xji@analogixsemi.com>
---
drivers/usb/typec/anx7411.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/typec/anx7411.c b/drivers/usb/typec/anx7411.c
index 7b45d7440a9d..dc86b6704cbd 100644
--- a/drivers/usb/typec/anx7411.c
+++ b/drivers/usb/typec/anx7411.c
@@ -550,6 +550,7 @@ static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
{
struct device *dev = &ctx->spi_client->dev;
struct typec_altmode_desc desc;
+ struct typec_altmode *alt;
int i;
desc.svid = svid;
@@ -566,14 +567,14 @@ static int anx7411_typec_register_altmode(struct anx7411_data *ctx,
return -ENOMEM;
}
- ctx->typec.amode[i] = typec_partner_register_altmode(ctx->typec.partner,
- &desc);
- if (IS_ERR(ctx->typec.amode[i])) {
+ alt = typec_partner_register_altmode(ctx->typec.partner, &desc);
+ if (IS_ERR(alt)) {
dev_err(dev, "failed to register altmode\n");
- ctx->typec.amode[i] = NULL;
- return PTR_ERR(ctx->typec.amode);
+ return PTR_ERR(alt);
}
+ ctx->typec.amode[i] = alt;
+
return 0;
}
--
2.25.1
next prev parent reply other threads:[~2022-07-22 8:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 8:18 [PATCH 1/3] usb: typec: anx7411: fix passing zero " Xin Ji
2022-07-22 8:18 ` Xin Ji [this message]
2022-07-27 12:28 ` [PATCH 2/3] usb: typec: anx7411: fix passing a valid pointer " Greg Kroah-Hartman
2022-07-22 8:18 ` [PATCH 3/3] usb: typec: anx7411: fix missing error code 'ret' Xin Ji
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220722081836.3380885-2-xji@analogixsemi.com \
--to=xji@analogixsemi.com \
--cc=bliang@analogixsemi.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jli@analogixsemi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=qwen@analogixsemi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®