diff mbox series

[net] can: mcp251xfd: fix an error pointer dereference in probe

Message ID YJANZf13Qxd5Mhr1@mwanda (mailing list archive)
State Awaiting Upstream
Delegated to: Netdev Maintainers
Headers show
Series [net] can: mcp251xfd: fix an error pointer dereference in probe | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Dan Carpenter May 3, 2021, 2:49 p.m. UTC
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(-)

Comments

Marc Kleine-Budde May 3, 2021, 2:53 p.m. UTC | #1
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
Manivannan Sadhasivam May 3, 2021, 4:47 p.m. UTC | #2
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
>
diff mbox series

Patch

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 */