Netdev Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH net] can: mcp251xfd: fix an error pointer dereference in probe
@ 2021-05-03 14:49 Dan Carpenter
  2021-05-03 14:53 ` Marc Kleine-Budde
  2021-05-03 16:47 ` Manivannan Sadhasivam
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2021-05-03 14:49 UTC (permalink / raw)
  To: Marc Kleine-Budde
  Cc: Manivannan Sadhasivam, Thomas Kopp, Wolfgang Grandegger,
	David S. Miller, Jakub Kicinski, linux-can, netdev,
	kernel-janitors

When we converted this code to use dev_err_probe() we accidentally
removed a return.  It means that if devm_clk_get() it will lead to
an Oops when we call clk_get_rate() on the next line.

Fixes: cf8ee6de2543 ("can: mcp251xfd: mcp251xfd_probe(): use dev_err_probe() to simplify error handling")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
index 970dc570e7a5..f122976e90da 100644
--- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
+++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
@@ -2885,8 +2885,8 @@ static int mcp251xfd_probe(struct spi_device *spi)
 
 	clk = devm_clk_get(&spi->dev, NULL);
 	if (IS_ERR(clk))
-		dev_err_probe(&spi->dev, PTR_ERR(clk),
-			      "Failed to get Oscillator (clock)!\n");
+		return dev_err_probe(&spi->dev, PTR_ERR(clk),
+				     "Failed to get Oscillator (clock)!\n");
 	freq = clk_get_rate(clk);
 
 	/* Sanity check */
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] can: mcp251xfd: fix an error pointer dereference in probe
  2021-05-03 14:49 [PATCH net] can: mcp251xfd: fix an error pointer dereference in probe Dan Carpenter
@ 2021-05-03 14:53 ` Marc Kleine-Budde
  2021-05-03 16:47 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Kleine-Budde @ 2021-05-03 14:53 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Manivannan Sadhasivam, Thomas Kopp, Wolfgang Grandegger,
	David S. Miller, Jakub Kicinski, linux-can, netdev,
	kernel-janitors


[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

On 03.05.2021 17:49:09, Dan Carpenter wrote:
> When we converted this code to use dev_err_probe() we accidentally
> removed a return.  It means that if devm_clk_get() it will lead to
> an Oops when we call clk_get_rate() on the next line.
> 
> Fixes: cf8ee6de2543 ("can: mcp251xfd: mcp251xfd_probe(): use dev_err_probe() to simplify error handling")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Good catch, found that yesterday, too, but haven't posted it here.

Marc
-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] can: mcp251xfd: fix an error pointer dereference in probe
  2021-05-03 14:49 [PATCH net] can: mcp251xfd: fix an error pointer dereference in probe Dan Carpenter
  2021-05-03 14:53 ` Marc Kleine-Budde
@ 2021-05-03 16:47 ` Manivannan Sadhasivam
  1 sibling, 0 replies; 3+ messages in thread
From: Manivannan Sadhasivam @ 2021-05-03 16:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Marc Kleine-Budde, Thomas Kopp, Wolfgang Grandegger,
	David S. Miller, Jakub Kicinski, linux-can, netdev,
	kernel-janitors

On Mon, May 03, 2021 at 05:49:09PM +0300, Dan Carpenter wrote:
> When we converted this code to use dev_err_probe() we accidentally
> removed a return.  It means that if devm_clk_get() it will lead to
> an Oops when we call clk_get_rate() on the next line.
> 
> Fixes: cf8ee6de2543 ("can: mcp251xfd: mcp251xfd_probe(): use dev_err_probe() to simplify error handling")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Manivannan Sadhasivam <mani@kernel.org>

Thanks,
Mani

> ---
>  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> index 970dc570e7a5..f122976e90da 100644
> --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> @@ -2885,8 +2885,8 @@ static int mcp251xfd_probe(struct spi_device *spi)
>  
>  	clk = devm_clk_get(&spi->dev, NULL);
>  	if (IS_ERR(clk))
> -		dev_err_probe(&spi->dev, PTR_ERR(clk),
> -			      "Failed to get Oscillator (clock)!\n");
> +		return dev_err_probe(&spi->dev, PTR_ERR(clk),
> +				     "Failed to get Oscillator (clock)!\n");
>  	freq = clk_get_rate(clk);
>  
>  	/* Sanity check */
> -- 
> 2.30.2
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 14:49 [PATCH net] can: mcp251xfd: fix an error pointer dereference in probe Dan Carpenter
2021-05-03 14:53 ` Marc Kleine-Budde
2021-05-03 16:47 ` Manivannan Sadhasivam

Netdev Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/netdev/0 netdev/git/0.git
	git clone --mirror https://lore.kernel.org/netdev/1 netdev/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 netdev netdev/ https://lore.kernel.org/netdev \
		netdev@vger.kernel.org
	public-inbox-index netdev

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.netdev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git