parport: Fix mem leak in parport_register_dev_model
Subsystems (7)
Sasha Levin
maintainerPATCH 1/10 parport: Fix mem leak in parport_register_dev_model
From: YueHaibing <[email protected]>
[ Upstream commit 1c7ebeabc9e5ee12e42075a597de40fdb9059530 ]
BUG: memory leak
unreferenced object 0xffff8881df48cda0 (size 16):
comm "syz-executor.0", pid 5077, jiffies 4295994670 (age 22.280s)
hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000d2d0d5fe>] parport_register_dev_model+0x141/0x6e0 [parport]
[<00000000782f6dab>] 0xffffffffc15d1196
[<00000000d2ca6ae4>] platform_drv_probe+0x7e/0x100
[<00000000628c2a94>] really_probe+0x342/0x4d0
[<000000006874f5da>] driver_probe_device+0x8c/0x170
[<00000000424de37a>] __device_attach_driver+0xda/0x100
[<000000002acab09a>] bus_for_each_drv+0xfe/0x170
[<000000003d9e5f31>] __device_attach+0x190/0x230
[<0000000035d32f80>] bus_probe_device+0x123/0x140
[<00000000a05ba627>] device_add+0x7cc/0xce0
[<000000003f7560bf>] platform_device_add+0x230/0x3c0
[<000000002a0be07d>] 0xffffffffc15d0949
[<000000007361d8d2>] port_check+0x3b/0x50 [parport]
[<000000004d67200f>] bus_for_each_dev+0x115/0x180
[<000000003ccfd11c>] __parport_register_driver+0x1f0/0x210 [parport]
[<00000000987f06fc>] 0xffffffffc15d803eAfter commit 4e5a74f1db8d ("parport: Revert "parport: fix memory leak""), free_pardevice do not free par_dev->state, we should free it in error path of parport_register_dev_model before return.
--- drivers/parport/share.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/parport/share.c +2 -0
@@ -892,6 +892,7 @@ parport_register_dev_model(struct parport *port, const char *name, par_dev->devmodel = true; ret =device_register (&par_dev->dev);if (ret) { +kfree (par_dev->state);put_device (&par_dev->dev); goto err_put_port; }
@@ -909,6 +910,7 @@ parport_register_dev_model(struct parport *port, const char *name,spin_unlock (&port->physport->pardevice_lock);pr_debug ("%s: cannot grant exclusive access for device %s\n" , port->name, name); +kfree (par_dev->state);device_unregister (&par_dev->dev); goto err_put_port; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 2/10 parisc: Fix compiler warnings in float emulation code
From: Helge Deller <[email protected]>
[ Upstream commit 6b98d9134e14f5ef4bcf64b27eedf484ed19a1ec ]
Avoid such compiler warnings:arch/parisc/math-emu/cnv_float.h:71:27: warning: ‘<<’ in boolean context, did you mean ‘<’ ? [-Wint-in-bool-context]
((Dintp1(dint_valueA) << 33 - SGL_EXP_LENGTH) || Dintp2(dint_valueB))
arch/parisc/math-emu/fcnvxf.c:257:6: note: in expansion of macro ‘Dint_isinexact_to_sgl’
if (Dint_isinexact_to_sgl(srcp1,srcp2)) {
--- arch/parisc/math-emu/cnv_float.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/parisc/math-emu/cnv_float.h +4 -4
@@ -60,19 +60,19 @@ ((exponent < (SGL_P -1 )) ? \ (Sall(sgl_value) << (SGL_EXP_LENGTH + 1 + exponent)) : FALSE) -#define Int_isinexact_to_sgl (int_value) (int_value << 33 - SGL_EXP_LENGTH) +#define Int_isinexact_to_sgl (int_value) ((int_value << 33 - SGL_EXP_LENGTH) != 0) #define Sgl_roundnearest_from_int(int_value,sgl_value) \ if (int_value & 1<<(SGL_EXP_LENGTH - 2)) /* round bit */ \ - if ((int_value << 34 - SGL_EXP_LENGTH) || Slow(sgl_value)) \ + if (((int_value << 34 - SGL_EXP_LENGTH) != 0) || Slow(sgl_value)) \ Sall(sgl_value)++#define Dint_isinexact_to_sgl (dint_valueA,dint_valueB) \ - ((Dintp1(dint_valueA) << 33 - SGL_EXP_LENGTH) || Dintp2(dint_valueB)) + (((Dintp1(dint_valueA) << 33 - SGL_EXP_LENGTH) != 0) || Dintp2(dint_valueB))#define Sgl_roundnearest_from_dint (dint_valueA,dint_valueB,sgl_value) \ if (Dintp1(dint_valueA) & 1<<(SGL_EXP_LENGTH - 2)) \ - if ((Dintp1(dint_valueA) << 34 - SGL_EXP_LENGTH) || \ + if (((Dintp1(dint_valueA) << 34 - SGL_EXP_LENGTH) != 0) || \ Dintp2(dint_valueB) || Slow(sgl_value)) Sall(sgl_value)++#define Dint_isinexact_to_dbl (dint_value) \
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 3/10 IB/hfi1: Insure freeze_work work_struct is canceled on shutdown
In reply to Sasha LevinFrom: Mike Marciniszyn <[email protected]>
[ Upstream commit 6d517353c70bb0818b691ca003afdcb5ee5ea44e ]
By code inspection, the freeze_work is never canceled.
Fix by adding a cancel_work_sync in the shutdown path to insure it is no longer running.
--- drivers/staging/rdma/hfi1/chip.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/rdma/hfi1/chip.c +1 -0
@@ -5906,6 +5906,7 @@ void hfi1_quiet_serdes(struct hfi1_pportdata *ppd)/* disable the port */ clear_rcvctrl (dd,RCV_CTRL_RCV_PORT_ENABLE_SMASK ); +cancel_work_sync (&ppd->freeze_work); }static inline int init_cpu_counters (struct hfi1_devdata *dd)
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 4/10 MIPS: uprobes: remove set but not used variable 'epc'
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit f532beeeff0c0a3586cc15538bc52d249eb19e7c ]
Fixes gcc '-Wunused-but-set-variable' warning:
arch/mips/kernel/uprobes.c: In function 'arch_uprobe_pre_xol':arch/mips/kernel/uprobes.c:115:17: warning: variable 'epc' set but not used [-Wunused-but-set-variable]
It's never used since introduction in commit 40e084a506eb ("MIPS: Add uprobes support.")
--- arch/mips/kernel/uprobes.c | 3 --- 1 file changed, 3 deletions(-)
arch/mips/kernel/uprobes.c +0 -3
@@ -164,9 +164,6 @@ int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs)*/ aup->resume_epc = regs->cp0_epc +4 ;if (insn_has_delay_slot ((union mips_instruction ) aup->insn[0 ])) { -unsigned long epc; - - epc = regs->cp0_epc;__compute_return_epc_for_insn (regs, (union mips_instruction ) aup->insn[0 ]); aup->resume_epc = regs->cp0_epc;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 5/10 net: hns: Fix loopback test failed at copper ports
In reply to Sasha LevinFrom: Yonglong Liu <[email protected]>
[ Upstream commit 2e1f164861e500f4e068a9d909bbd3fcc7841483 ]
When doing a loopback test at copper ports, the serdes loopback and the phy loopback will fail, because of the adjust link had not finished, and phy not ready.
Adds sleep between adjust link and test process to fix it.
--- drivers/net/ethernet/hisilicon/hns/hns_ethtool.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +4 -0
@@ -351,6 +351,7 @@ static int __lb_setup(struct net_device *ndev,static int __lb_up (struct net_device *ndev,enum hnae_loop loop_mode) { +#define NIC_LB_TEST_WAIT_PHY_LINK_TIME 300struct hns_nic_priv *priv =netdev_priv (ndev);struct hnae_handle *h = priv->ae_handle;int speed, duplex;
@@ -389,6 +390,9 @@ static int __lb_up(struct net_device *ndev, h->dev->ops->adjust_link (h, speed, duplex); +/* wait adjust link done and phy ready */ +msleep (NIC_LB_TEST_WAIT_PHY_LINK_TIME ); +return 0 ; }
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 6/10 sparc: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD
In reply to Sasha LevinFrom: Young Xiao <[email protected]>
[ Upstream commit 56cd0aefa475079e9613085b14a0f05037518fed ]
The PERF_EVENT_IOC_PERIOD ioctl command can be used to change the sample period of a running perf_event. Consequently, when calculating the next event period, the new period will only be considered after the previous one has overflowed.
This patch changes the calculation of the remaining event ticks so that they are offset if the period has changed.
See commit 3581fe0ef37c ("ARM: 7556/1: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD") for details.
--- arch/sparc/kernel/perf_event.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/sparc/kernel/perf_event.c +4 -0
@@ -889,6 +889,10 @@ static int sparc_perf_event_set_period(struct perf_event *event,s64 period = hwc->sample_period;int ret =0 ; +/* The period may have been changed by PERF_EVENT_IOC_PERIOD */ +if (unlikely (period != hwc->last_period)) + left = period - (hwc->last_period - left); +if (unlikely (left <= -period)) { left = period;local64_set (&hwc->period_left, left);
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 7/10 scripts/checkstack.pl: Fix arm64 wrong or unknown architecture
In reply to Sasha LevinFrom: "George G. Davis" <[email protected]>
[ Upstream commit 4f45d62a52297b10ded963412a158685647ecdec ]
The following error occurs for the make ARCH=arm64 checkstack case:
aarch64-linux-gnu-objdump -d vmlinux $(find . -name '*.ko') | \
perl ./scripts/checkstack.pl arm64
wrong or unknown architecture "arm64"
As suggested by Masahiro Yamada, fix the above error using regular expressions in the same way it was fixed for the ARCH=x86 case via commit fda9f9903be6 ("scripts/checkstack.pl: automatically handle 32-bit and 64-bit mode for ARCH=x86").
--- scripts/checkstack.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkstack.pl +1 -1
@@ -45,7 +45,7 @@ my (@stack, $re, $dre, $x, $xs, $funcre); $x = "[0-9a-f]"; # hex character $xs = "[0-9a-f ]"; # hex character or space $funcre = qr/^$x* <(.*)>:$/; - if ($arch eq 'aarch64') { + if ($arch =~ '^(aarch|arm)64$') { #ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp, #-80]! $re = qr/^.*stp.*sp, \#-([0-9]{1,8})\]\!/o; } elsif ($arch eq 'arm') {
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 8/10 scsi: ufs: Check that space was properly alloced in copy_query_response
In reply to Sasha LevinFrom: Avri Altman <[email protected]>
[ Upstream commit 1c90836f70f9a8ef7b7ad9e1fdd8961903e6ced6 ]
struct ufs_dev_cmd is the main container that supports device management commands. In the case of a read descriptor request, we assume that the proper space was allocated in dev_cmd to hold the returning descriptor.
This is no longer true, as there are flows that doesn't use dev_cmd for device management requests, and was wrong in the first place.
--- drivers/scsi/ufs/ufshcd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/scsi/ufs/ufshcd.c +2 -1
@@ -853,7 +853,8 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)memcpy (&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr,QUERY_OSF_SIZE );/* Get the descriptor */ -if (lrbp->ucd_rsp_ptr->qr.opcode ==UPIU_QUERY_OPCODE_READ_DESC ) { +if (hba->dev_cmd.query.descriptor && + lrbp->ucd_rsp_ptr->qr.opcode ==UPIU_QUERY_OPCODE_READ_DESC ) {u8 *descp = (u8 *)lrbp->ucd_rsp_ptr +GENERAL_UPIU_REQUEST_SIZE ;u16 resp_len;
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 9/10 s390/qeth: fix VLAN attribute in bridge_hostnotify udev event
In reply to Sasha LevinFrom: Alexandra Winter <[email protected]>
[ Upstream commit 335726195e460cb6b3f795b695bfd31f0ea70ef0 ]
Enabling sysfs attribute bridge_hostnotify triggers a series of udev events for the MAC addresses of all currently connected peers. In case no VLAN is set for a peer, the device reports the corresponding MAC addresses with VLAN ID 4096. This currently results in attribute VLAN=4096 for all non-VLAN interfaces in the initial series of events after host-notify is enabled.
Instead, no VLAN attribute should be reported in the udev event for non-VLAN interfaces.
Only the initial events face this issue. For dynamic changes that are reported later, the device uses a validity flag.
This also changes the code so that it now sets the VLAN attribute for MAC addresses with VID 0. On Linux, no qeth interface will ever be registered with VID 0: Linux kernel registers VID 0 on all network interfaces initially, but qeth will drop .ndo_vlan_rx_add_vid for VID 0. Peers with other OSs could register MACs with VID 0.
--- drivers/s390/net/qeth_l2_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_l2_main.c +1 -1
@@ -2112,7 +2112,7 @@ static void qeth_bridgeport_an_set_cb(void *priv, l2entry = (struct qdio_brinfo_entry_l2 *)entry; code =IPA_ADDR_CHANGE_CODE_MACADDR ; -if (l2entry->addr_lnid.lnid) +if (l2entry->addr_lnid.lnid <VLAN_N_VID ) code |=IPA_ADDR_CHANGE_CODE_VLANID ; qeth_bridge_emit_host_event(card, anev_reg_unreg, code, (struct net_if_token *)&l2entry->nit,
Signature · 1 line
2.20.1
Sasha Levin
maintainerPATCH 10/10 hwmon: (pmbus/core) Treat parameters as paged if on multiple pages
In reply to Sasha LevinFrom: Robert Hancock <[email protected]>
[ Upstream commit 4a60570dce658e3f8885bbcf852430b99f65aca5 ]
Some chips have attributes which exist on more than one page but the attribute is not presently marked as paged. This causes the attributes to be generated with the same label, which makes it impossible for userspace to tell them apart.
Marking all such attributes as paged would result in the page suffix being added regardless of whether they were present on more than one page or not, which might break existing setups. Therefore, we add a second check which treats the attribute as paged, even if not marked as such, if it is present on multiple pages.
--- drivers/hwmon/pmbus/pmbus_core.c | 34 ++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-)
drivers/hwmon/pmbus/pmbus_core.c +30 -4
@@ -1028,14 +1028,15 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,const struct pmbus_driver_info *info, const char *name, int index, int page, - const struct pmbus_sensor_attr *attr) + const struct pmbus_sensor_attr *attr, + bool paged) { struct pmbus_sensor *base;int ret;if (attr->label) { ret =pmbus_add_label (data, name, index, attr->label, - attr->paged ? page +1 :0 ); + paged ? page +1 :0 );if (ret)return ret; }
@@ -1067,6 +1068,30 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client,return 0 ; } +static bool pmbus_sensor_is_paged (const struct pmbus_driver_info *info, +const struct pmbus_sensor_attr *attr) +{ +int p; + +if (attr->paged) +return true; + +/* +* Some attributes may be present on more than one page despite +* not being marked with the paged attribute. If that is the case, +* then treat the sensor as being paged and add the page suffix to the +* attribute name. +* We don't just add the paged attribute to all such attributes, in +* order to maintain the un-suffixed labels in the case where the +* attribute is only on page 0. +*/ +for (p =1 ; p < info->pages; p++) { +if (info->func[p] & attr->func) +return true; + } +return false; +} + static int pmbus_add_sensor_attrs(struct i2c_client *client, struct pmbus_data *data, const char *name,
@@ -1080,14 +1105,15 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client, index =1 ;for (i =0 ; i < nattrs; i++) {int page, pages; +bool paged =pmbus_sensor_is_paged (info, attrs); - pages = attrs->paged ? info->pages :1 ; + pages = paged ? info->pages :1 ;for (page =0 ; page < pages; page++) {if (!(info->func[page] & attrs->func))continue ; ret =pmbus_add_sensor_attrs_one (client, data, info, name, index, page, - attrs); + attrs, paged);if (ret)return ret; index++;
Signature · 1 line
2.20.1