From: walter harms <wharms@bfs.de>
To: Silvan Jegen <s.jegen@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH v2] [media] mantis: fix error handling
Date: Sun, 22 Mar 2015 19:33:43 +0000 [thread overview]
Message-ID: <550F1917.1080602@bfs.de> (raw)
In-Reply-To: <1427044578-16551-1-git-send-email-s.jegen@gmail.com>
Am 22.03.2015 18:16, schrieb Silvan Jegen:
> Remove dead code, make goto label names more expressive and add a label
> in order to call mantis_dvb_exit if mantis_uart_init fails.
>
> Also make sure that mantis_pci_exit is called if we fail the
> mantis_stream_control call and that we call mantis_i2c_exit if
> mantis_get_mac fails.
>
> Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
> ---
> V2 Changes (due to Dan Carpenter's review):
> - Remove dead code, do not activate it
> - Make goto labels more expressive
> - Add a call to mantis_dvb_exit
>
> drivers/media/pci/mantis/mantis_cards.c | 33 ++++++++++++++++-----------------
> 1 file changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/media/pci/mantis/mantis_cards.c b/drivers/media/pci/mantis/mantis_cards.c
> index 801fc55..70df61e 100644
> --- a/drivers/media/pci/mantis/mantis_cards.c
> +++ b/drivers/media/pci/mantis/mantis_cards.c
> @@ -170,7 +170,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
> if (mantis = NULL) {
> printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
> err = -ENOMEM;
> - goto fail0;
> + return err;
> }
>
> mantis->num = devs;
> @@ -183,70 +183,69 @@ static int mantis_pci_probe(struct pci_dev *pdev,
> err = mantis_pci_init(mantis);
> if (err) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
> - goto fail1;
> + goto err_free_mantis;
> }
>
> err = mantis_stream_control(mantis, STREAM_TO_HIF);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
> - goto fail1;
> + goto err_pci_exit;
> }
>
> err = mantis_i2c_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
> - goto fail2;
> + goto err_pci_exit;
> }
>
> err = mantis_get_mac(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
> - goto fail2;
> + goto err_i2c_exit;
> }
>
> err = mantis_dma_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
> - goto fail3;
> + goto err_i2c_exit;
> }
>
> err = mantis_dvb_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
> - goto fail4;
> + goto err_dma_exit;
> }
> +
> err = mantis_uart_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err);
> - goto fail6;
> + goto err_dvb_exit;
> }
>
> devs++;
>
> return err;
>
Hi Silvan Jegen,
i found the dprintk() a bit confusing, if i understand the code correctly it will always print on error:
the dprintf found in if (err<0) like :
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
and then
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB exit! <%d>", err);
maybe this is more a question for the maintainer, but this seems a bit useless.
re,
wh
> +err_dvb_exit:
> + dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB exit! <%d>", err);
> + mantis_dvb_exit(mantis);
>
> - dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err);
> - mantis_uart_exit(mantis);
> -
> -fail6:
> -fail4:
> +err_dma_exit:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
> mantis_dma_exit(mantis);
>
> -fail3:
> +err_i2c_exit:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
> mantis_i2c_exit(mantis);
>
> -fail2:
> +err_pci_exit:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
> mantis_pci_exit(mantis);
>
> -fail1:
> +err_free_mantis:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
> kfree(mantis);
>
> -fail0:
> return err;
> }
>
WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Silvan Jegen <s.jegen@gmail.com>
Cc: Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org,
Dan Carpenter <dan.carpenter@oracle.com>
Subject: Re: [PATCH v2] [media] mantis: fix error handling
Date: Sun, 22 Mar 2015 20:33:43 +0100 [thread overview]
Message-ID: <550F1917.1080602@bfs.de> (raw)
In-Reply-To: <1427044578-16551-1-git-send-email-s.jegen@gmail.com>
Am 22.03.2015 18:16, schrieb Silvan Jegen:
> Remove dead code, make goto label names more expressive and add a label
> in order to call mantis_dvb_exit if mantis_uart_init fails.
>
> Also make sure that mantis_pci_exit is called if we fail the
> mantis_stream_control call and that we call mantis_i2c_exit if
> mantis_get_mac fails.
>
> Signed-off-by: Silvan Jegen <s.jegen@gmail.com>
> ---
> V2 Changes (due to Dan Carpenter's review):
> - Remove dead code, do not activate it
> - Make goto labels more expressive
> - Add a call to mantis_dvb_exit
>
> drivers/media/pci/mantis/mantis_cards.c | 33 ++++++++++++++++-----------------
> 1 file changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/media/pci/mantis/mantis_cards.c b/drivers/media/pci/mantis/mantis_cards.c
> index 801fc55..70df61e 100644
> --- a/drivers/media/pci/mantis/mantis_cards.c
> +++ b/drivers/media/pci/mantis/mantis_cards.c
> @@ -170,7 +170,7 @@ static int mantis_pci_probe(struct pci_dev *pdev,
> if (mantis == NULL) {
> printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
> err = -ENOMEM;
> - goto fail0;
> + return err;
> }
>
> mantis->num = devs;
> @@ -183,70 +183,69 @@ static int mantis_pci_probe(struct pci_dev *pdev,
> err = mantis_pci_init(mantis);
> if (err) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI initialization failed <%d>", err);
> - goto fail1;
> + goto err_free_mantis;
> }
>
> err = mantis_stream_control(mantis, STREAM_TO_HIF);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis stream control failed <%d>", err);
> - goto fail1;
> + goto err_pci_exit;
> }
>
> err = mantis_i2c_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C initialization failed <%d>", err);
> - goto fail2;
> + goto err_pci_exit;
> }
>
> err = mantis_get_mac(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis MAC address read failed <%d>", err);
> - goto fail2;
> + goto err_i2c_exit;
> }
>
> err = mantis_dma_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA initialization failed <%d>", err);
> - goto fail3;
> + goto err_i2c_exit;
> }
>
> err = mantis_dvb_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
> - goto fail4;
> + goto err_dma_exit;
> }
> +
> err = mantis_uart_init(mantis);
> if (err < 0) {
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART initialization failed <%d>", err);
> - goto fail6;
> + goto err_dvb_exit;
> }
>
> devs++;
>
> return err;
>
Hi Silvan Jegen,
i found the dprintk() a bit confusing, if i understand the code correctly it will always print on error:
the dprintf found in if (err<0) like :
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB initialization failed <%d>", err);
and then
dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB exit! <%d>", err);
maybe this is more a question for the maintainer, but this seems a bit useless.
re,
wh
> +err_dvb_exit:
> + dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DVB exit! <%d>", err);
> + mantis_dvb_exit(mantis);
>
> - dprintk(MANTIS_ERROR, 1, "ERROR: Mantis UART exit! <%d>", err);
> - mantis_uart_exit(mantis);
> -
> -fail6:
> -fail4:
> +err_dma_exit:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis DMA exit! <%d>", err);
> mantis_dma_exit(mantis);
>
> -fail3:
> +err_i2c_exit:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis I2C exit! <%d>", err);
> mantis_i2c_exit(mantis);
>
> -fail2:
> +err_pci_exit:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis PCI exit! <%d>", err);
> mantis_pci_exit(mantis);
>
> -fail1:
> +err_free_mantis:
> dprintk(MANTIS_ERROR, 1, "ERROR: Mantis free! <%d>", err);
> kfree(mantis);
>
> -fail0:
> return err;
> }
>
next prev parent reply other threads:[~2015-03-22 19:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-15 12:11 [PATCH 0/2] [media] mantis: Fix goto labels Silvan Jegen
2015-02-15 12:11 ` Silvan Jegen
2015-02-15 12:11 ` [PATCH 1/2] [media] mantis: Move jump label to activate dead code Silvan Jegen
2015-02-15 12:11 ` Silvan Jegen
2015-02-16 9:04 ` Dan Carpenter
2015-02-16 9:04 ` Dan Carpenter
2015-02-17 9:48 ` Silvan Jegen
2015-02-17 9:48 ` Silvan Jegen
2015-03-22 17:16 ` [PATCH v2] [media] mantis: fix error handling Silvan Jegen
2015-03-22 17:16 ` Silvan Jegen
2015-03-22 19:33 ` walter harms [this message]
2015-03-22 19:33 ` walter harms
2015-03-22 22:48 ` Dan Carpenter
2015-03-22 22:48 ` Dan Carpenter
2015-03-23 16:25 ` [PATCH V3] " Silvan Jegen
2015-03-23 16:25 ` Silvan Jegen
2015-03-23 16:32 ` Dan Carpenter
2015-03-23 16:32 ` Dan Carpenter
2015-02-15 12:11 ` [PATCH 2/2] [media] mantis: Use correct goto labels for cleanup on error Silvan Jegen
2015-02-15 12:11 ` Silvan Jegen
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=550F1917.1080602@bfs.de \
--to=wharms@bfs.de \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@osg.samsung.com \
--cc=s.jegen@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.