* [PATCH] pcmcia: add error handling for pcmcia_enable_device
@ 2018-06-11 5:15 Zhouyang Jia
2018-06-11 7:21 ` Johannes Thumshirn
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Zhouyang Jia @ 2018-06-11 5:15 UTC (permalink / raw)
Cc: Zhouyang Jia, James E.J. Bottomley, Martin K. Petersen,
Johannes Thumshirn, Hannes Reinecke, linux-scsi, linux-kernel
When pcmcia_enable_device fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling pcmcia_enable_device.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/scsi/pcmcia/qlogic_stub.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 0556054..9287d52 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -254,8 +254,14 @@ static void qlogic_release(struct pcmcia_device *link)
static int qlogic_resume(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
+ int ret;
+
+ ret = pcmcia_enable_device(link);
+ if (ret) {
+ pcmcia_disable_device(link);
+ return -ENODEV;
+ }
- pcmcia_enable_device(link);
if ((info->manf_id == MANFID_MACNICA) ||
(info->manf_id == MANFID_PIONEER) ||
(info->manf_id == 0x0098)) {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] pcmcia: add error handling for pcmcia_enable_device
2018-06-11 5:15 [PATCH] pcmcia: add error handling for pcmcia_enable_device Zhouyang Jia
@ 2018-06-11 7:21 ` Johannes Thumshirn
2018-06-14 9:23 ` [PATCH v2] " Zhouyang Jia
2018-06-14 23:41 ` [PATCH v3] " Zhouyang Jia
2 siblings, 0 replies; 5+ messages in thread
From: Johannes Thumshirn @ 2018-06-11 7:21 UTC (permalink / raw)
To: Zhouyang Jia
Cc: James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
linux-scsi, linux-kernel
On Mon, Jun 11, 2018 at 01:15:50PM +0800, Zhouyang Jia wrote:
> When pcmcia_enable_device fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling pcmcia_enable_device.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> drivers/scsi/pcmcia/qlogic_stub.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
> index 0556054..9287d52 100644
> --- a/drivers/scsi/pcmcia/qlogic_stub.c
> +++ b/drivers/scsi/pcmcia/qlogic_stub.c
> @@ -254,8 +254,14 @@ static void qlogic_release(struct pcmcia_device *link)
> static int qlogic_resume(struct pcmcia_device *link)
> {
> scsi_info_t *info = link->priv;
> + int ret;
> +
> + ret = pcmcia_enable_device(link);
> + if (ret) {
> + pcmcia_disable_device(link);
> + return -ENODEV;
> + }
pcmcia_enable_device() can fail for three reasons:
1) the socket is not present
2) the configuration is locked
3) setting the socket's power control fails
In all three cases I think it's actually an error to call
pcmcia_disable_device().
Imagine the following scenario:
pcmcia_enable_device() failed because the device configuration is
locked by another driver, then you call pcmcia_disable_device() which
calls pcmcia_release_configuration(). pcmcia_release_configuration()
checks if the device is locked, decrements the lock counter, clears
the CONFIG_LOCKED bit in the PCMCIA config and sets the voltage to 0
without the first driver every noticing it.
Byte,
Johannes
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] pcmcia: add error handling for pcmcia_enable_device
2018-06-11 5:15 [PATCH] pcmcia: add error handling for pcmcia_enable_device Zhouyang Jia
2018-06-11 7:21 ` Johannes Thumshirn
@ 2018-06-14 9:23 ` Zhouyang Jia
2018-06-14 9:39 ` Andy Shevchenko
2018-06-14 23:41 ` [PATCH v3] " Zhouyang Jia
2 siblings, 1 reply; 5+ messages in thread
From: Zhouyang Jia @ 2018-06-14 9:23 UTC (permalink / raw)
Cc: Zhouyang Jia, James E.J. Bottomley, Martin K. Petersen,
Johannes Thumshirn, Hannes Reinecke, linux-scsi, linux-kernel
When pcmcia_enable_device fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling pcmcia_enable_device.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Remove pcmcia_disable_device.
---
drivers/scsi/pcmcia/qlogic_stub.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 0556054..eb2c8bf 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -254,8 +254,12 @@ static void qlogic_release(struct pcmcia_device *link)
static int qlogic_resume(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
+ int ret;
+
+ ret = pcmcia_enable_device(link);
+ if (ret)
+ return -ENODEV;
- pcmcia_enable_device(link);
if ((info->manf_id == MANFID_MACNICA) ||
(info->manf_id == MANFID_PIONEER) ||
(info->manf_id == 0x0098)) {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pcmcia: add error handling for pcmcia_enable_device
2018-06-14 9:23 ` [PATCH v2] " Zhouyang Jia
@ 2018-06-14 9:39 ` Andy Shevchenko
0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2018-06-14 9:39 UTC (permalink / raw)
To: Zhouyang Jia
Cc: James E.J. Bottomley, Martin K. Petersen, Johannes Thumshirn,
Hannes Reinecke, linux-scsi, Linux Kernel Mailing List
On Thu, Jun 14, 2018 at 12:23 PM, Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
> When pcmcia_enable_device fails, the lack of error-handling code may
> cause unexpected results.
What results?
You need to elaborate this.,
> This patch adds error-handling code after calling pcmcia_enable_device.
> + int ret;
> +
> + ret = pcmcia_enable_device(link);
> + if (ret)
> + return -ENODEV;
And why not to return ret?
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] pcmcia: add error handling for pcmcia_enable_device
2018-06-11 5:15 [PATCH] pcmcia: add error handling for pcmcia_enable_device Zhouyang Jia
2018-06-11 7:21 ` Johannes Thumshirn
2018-06-14 9:23 ` [PATCH v2] " Zhouyang Jia
@ 2018-06-14 23:41 ` Zhouyang Jia
2 siblings, 0 replies; 5+ messages in thread
From: Zhouyang Jia @ 2018-06-14 23:41 UTC (permalink / raw)
Cc: Zhouyang Jia, James E.J. Bottomley, Martin K. Petersen,
Hannes Reinecke, Johannes Thumshirn, linux-scsi, linux-kernel
When pcmcia_enable_device fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling pcmcia_enable_device.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
v1->v2:
- Remove pcmcia_disable_device.
v2->v3:
- Change the return value.
---
drivers/scsi/pcmcia/qlogic_stub.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 0556054..9d5751a 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -254,8 +254,12 @@ static void qlogic_release(struct pcmcia_device *link)
static int qlogic_resume(struct pcmcia_device *link)
{
scsi_info_t *info = link->priv;
+ int ret;
+
+ ret = pcmcia_enable_device(link);
+ if (ret)
+ return ret;
- pcmcia_enable_device(link);
if ((info->manf_id == MANFID_MACNICA) ||
(info->manf_id == MANFID_PIONEER) ||
(info->manf_id == 0x0098)) {
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-06-14 23:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11 5:15 [PATCH] pcmcia: add error handling for pcmcia_enable_device Zhouyang Jia
2018-06-11 7:21 ` Johannes Thumshirn
2018-06-14 9:23 ` [PATCH v2] " Zhouyang Jia
2018-06-14 9:39 ` Andy Shevchenko
2018-06-14 23:41 ` [PATCH v3] " Zhouyang Jia
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).