phy: usb: free the buffer after reading a given nvmem cell
Subsystems (3)
Vincent Shih
maintainerPATCH 1/1 phy: usb: free the buffer after reading a given nvmem cell
Use kfree() to free the buffer after calling nvmem_cell_read() to read a given nvmem cell.
--- drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/phy/sunplus/phy-sunplus-usb2.c +7 -3
@@ -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 <[email protected]>" );MODULE_DESCRIPTION ("Sunplus USB 2.0 phy driver" );MODULE_LICENSE ("GPL" ); +
Signature · 1 line
2.7.4
Greg KH
maintainerQuoted 4 lines · Vincent Shih
Use
kfree()to free the buffer after callingnvmem_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.
Quoted 37 lines
Signed-off-by Vincent Shih <[email protected]>--- drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/phy/sunplus/phy-sunplus-usb2.c +6
-3@@ -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 );
drivers/phy/sunplus/phy-sunplus-usb2.c module_platform_driver(sunplus_usb_phy_driver); · line 300
Quoted 4 lines
drivers/phy/sunplus/phy-sunplus-usb2.c +1
-0@@ -294,3 +297,4 @@ module_platform_driver(sunplus_usb_phy_driver);MODULE_AUTHOR ("Vincent Shih <[email protected]>" );MODULE_DESCRIPTION ("Sunplus USB 2.0 phy driver" );MODULE_LICENSE ("GPL" ); +
Why the extra blank line?
thanks,
greg k-h
Hello!
Quoted 2 lines · Vincent Shih
Use
kfree()to free the buffer after callingnvmem_cell_read()to read a given nvmem cell.
Your patch does more than just that. It looks like we need 2 patches here...
Quoted 1 line
Fixes 99d9ccd97385("phy: usb: Add USB2.0 phy driver for Sunplus SP7021")
Need spaces after : and before (.
Quoted 9 lines
Signed-off-by Vincent Shih <[email protected]>--- drivers/phy/sunplus/phy-sunplus-usb2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)drivers/phy/sunplus/phy-sunplus-usb2.c +0
-0
[...]
drivers/phy/sunplus/phy-sunplus-usb2.c static int update_disc_vol(struct sp_usbphy *usbphy) · line 96
Quoted 6 lines
drivers/phy/sunplus/phy-sunplus-usb2.c +1
-1@@ -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...
Quoted 14 lines
drivers/phy/sunplus/phy-sunplus-usb2.c +4
-2set = *(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 );
drivers/phy/sunplus/phy-sunplus-usb2.c module_platform_driver(sunplus_usb_phy_driver); · line 300
Quoted 4 lines
drivers/phy/sunplus/phy-sunplus-usb2.c +1
-0@@ -294,3 +297,4 @@ module_platform_driver(sunplus_usb_phy_driver);MODULE_AUTHOR ("Vincent Shih <[email protected]>" );MODULE_DESCRIPTION ("Sunplus USB 2.0 phy driver" );MODULE_LICENSE ("GPL" ); +
Huh? :-)
MBR, Sergey