* [PATCH] phy: usb: free the buffer after reading a given nvmem cell
@ 2022-09-06 6:23 Vincent Shih
2022-09-06 6:38 ` Greg KH
2022-09-06 8:27 ` Sergey Shtylyov
0 siblings, 2 replies; 3+ messages in thread
From: Vincent Shih @ 2022-09-06 6:23 UTC (permalink / raw)
To: kishon, vkoul, linux-usb, linux-phy, linux-kernel, wells.lu; +Cc: Vincent Shih
Use kfree() to free the buffer after calling nvmem_cell_read() to
read a given nvmem cell.
Fixes:99d9ccd97385("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Signed-off-by: Vincent Shih <vincent.sunplus@gmail.com>
---
drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
index 5269968..c8540e1 100644
--- a/drivers/phy/sunplus/phy-sunplus-usb2.c
+++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
@@ -13,6 +13,7 @@
#include <linux/bitfield.h>
#include <linux/clk.h>
#include <linux/delay.h>
+#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/nvmem-consumer.h>
@@ -92,13 +93,15 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
otp_v = nvmem_cell_read(cell, &otp_l);
nvmem_cell_put(cell);
- if (otp_v) {
+ if (!IS_ERR(otp_v)) {
set = *(otp_v + 1);
set = (set << (sizeof(char) * 8)) | *otp_v;
set = (set >> usbphy->disc_vol_addr_off) & J_DISC;
+
+ kfree(otp_v);
}
-
- if (!otp_v || set == 0)
+
+ if (IS_ERR(otp_v) || (set == 0))
set = OTP_DISC_LEVEL_DEFAULT;
val = readl(usbphy->phy_regs + CONFIG7);
@@ -294,3 +297,4 @@ module_platform_driver(sunplus_usb_phy_driver);
MODULE_AUTHOR("Vincent Shih <vincent.shih@sunplus.com>");
MODULE_DESCRIPTION("Sunplus USB 2.0 phy driver");
MODULE_LICENSE("GPL");
+
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: usb: free the buffer after reading a given nvmem cell
2022-09-06 6:23 [PATCH] phy: usb: free the buffer after reading a given nvmem cell Vincent Shih
@ 2022-09-06 6:38 ` Greg KH
2022-09-06 8:27 ` Sergey Shtylyov
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2022-09-06 6:38 UTC (permalink / raw)
To: Vincent Shih; +Cc: kishon, vkoul, linux-usb, linux-phy, linux-kernel, wells.lu
On Tue, Sep 06, 2022 at 02:23:02PM +0800, Vincent Shih wrote:
> Use kfree() to free the buffer after calling nvmem_cell_read() to
> read a given nvmem cell.
>
> Fixes:99d9ccd97385("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
This is not a commit in Linus's tree, are you sure it is right?
And the format is not quite correct, you need some spaces in the line.
> Signed-off-by: Vincent Shih <vincent.sunplus@gmail.com>
> ---
> drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
> index 5269968..c8540e1 100644
> --- a/drivers/phy/sunplus/phy-sunplus-usb2.c
> +++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
> @@ -13,6 +13,7 @@
> #include <linux/bitfield.h>
> #include <linux/clk.h>
> #include <linux/delay.h>
> +#include <linux/err.h>
> #include <linux/io.h>
> #include <linux/module.h>
> #include <linux/nvmem-consumer.h>
> @@ -92,13 +93,15 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
> otp_v = nvmem_cell_read(cell, &otp_l);
> nvmem_cell_put(cell);
>
> - if (otp_v) {
> + if (!IS_ERR(otp_v)) {
> set = *(otp_v + 1);
> set = (set << (sizeof(char) * 8)) | *otp_v;
> set = (set >> usbphy->disc_vol_addr_off) & J_DISC;
> +
> + kfree(otp_v);
> }
> -
> - if (!otp_v || set == 0)
> +
> + if (IS_ERR(otp_v) || (set == 0))
> set = OTP_DISC_LEVEL_DEFAULT;
>
> val = readl(usbphy->phy_regs + CONFIG7);
> @@ -294,3 +297,4 @@ module_platform_driver(sunplus_usb_phy_driver);
> MODULE_AUTHOR("Vincent Shih <vincent.shih@sunplus.com>");
> MODULE_DESCRIPTION("Sunplus USB 2.0 phy driver");
> MODULE_LICENSE("GPL");
> +
Why the extra blank line?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] phy: usb: free the buffer after reading a given nvmem cell
2022-09-06 6:23 [PATCH] phy: usb: free the buffer after reading a given nvmem cell Vincent Shih
2022-09-06 6:38 ` Greg KH
@ 2022-09-06 8:27 ` Sergey Shtylyov
1 sibling, 0 replies; 3+ messages in thread
From: Sergey Shtylyov @ 2022-09-06 8:27 UTC (permalink / raw)
To: Vincent Shih, kishon, vkoul, linux-usb, linux-phy, linux-kernel,
wells.lu
Hello!
On 9/6/22 9:23 AM, Vincent Shih wrote:
> Use kfree() to free the buffer after calling nvmem_cell_read() to
> read a given nvmem cell.
Your patch does more than just that. It looks like we need 2 patches here...
> Fixes:99d9ccd97385("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Need spaces after : and before (.
> Signed-off-by: Vincent Shih <vincent.sunplus@gmail.com>
> ---
> drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/phy/sunplus/phy-sunplus-usb2.c b/drivers/phy/sunplus/phy-sunplus-usb2.c
> index 5269968..c8540e1 100644
> --- a/drivers/phy/sunplus/phy-sunplus-usb2.c
> +++ b/drivers/phy/sunplus/phy-sunplus-usb2.c
[...]
> @@ -92,13 +93,15 @@ static int update_disc_vol(struct sp_usbphy *usbphy)
> otp_v = nvmem_cell_read(cell, &otp_l);
> nvmem_cell_put(cell);
>
> - if (otp_v) {
> + if (!IS_ERR(otp_v)) {
This needs a separate patch, I think...
> set = *(otp_v + 1);
> set = (set << (sizeof(char) * 8)) | *otp_v;
> set = (set >> usbphy->disc_vol_addr_off) & J_DISC;
> +
> + kfree(otp_v);
> }
> -
> - if (!otp_v || set == 0)
> +
> + if (IS_ERR(otp_v) || (set == 0))
> set = OTP_DISC_LEVEL_DEFAULT;
>
> val = readl(usbphy->phy_regs + CONFIG7);
> @@ -294,3 +297,4 @@ module_platform_driver(sunplus_usb_phy_driver);
> MODULE_AUTHOR("Vincent Shih <vincent.shih@sunplus.com>");
> MODULE_DESCRIPTION("Sunplus USB 2.0 phy driver");
> MODULE_LICENSE("GPL");
> +
Huh? :-)
MBR, Sergey
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-06 8:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-06 6:23 [PATCH] phy: usb: free the buffer after reading a given nvmem cell Vincent Shih
2022-09-06 6:38 ` Greg KH
2022-09-06 8:27 ` Sergey Shtylyov
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).