* [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check
@ 2020-02-21 23:11 ` Colin King
0 siblings, 0 replies; 9+ messages in thread
From: Colin King @ 2020-02-21 23:11 UTC (permalink / raw)
To: Roy Pledge, Li Yang, Youri Querry, linuxppc-dev, linux-arm-kernel
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
Pointer p is currently being dereferenced before it is null
checked on a memory allocation failure check. Fix this by
checking if p is null before dereferencing it.
Addresses-Coverity: ("Dereference before null check")
Fixes: 3b2abda7d28c ("soc: fsl: dpio: Replace QMAN array mode with ring mode enqueue")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/soc/fsl/dpio/qbman-portal.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c
index 740ee0d19582..d1f49caa5b13 100644
--- a/drivers/soc/fsl/dpio/qbman-portal.c
+++ b/drivers/soc/fsl/dpio/qbman-portal.c
@@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
u32 mask_size;
u32 eqcr_pi;
- spin_lock_init(&p->access_spinlock);
-
if (!p)
return NULL;
+
+ spin_lock_init(&p->access_spinlock);
+
p->desc = d;
p->mc.valid_bit = QB_VALID_BIT;
p->sdq = 0;
--
2.25.0
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check @ 2020-02-21 23:11 ` Colin King 0 siblings, 0 replies; 9+ messages in thread From: Colin King @ 2020-02-21 23:11 UTC (permalink / raw) To: Roy Pledge, Li Yang, Youri Querry, linuxppc-dev, linux-arm-kernel Cc: kernel-janitors, linux-kernel From: Colin Ian King <colin.king@canonical.com> Pointer p is currently being dereferenced before it is null checked on a memory allocation failure check. Fix this by checking if p is null before dereferencing it. Addresses-Coverity: ("Dereference before null check") Fixes: 3b2abda7d28c ("soc: fsl: dpio: Replace QMAN array mode with ring mode enqueue") Signed-off-by: Colin Ian King <colin.king@canonical.com> --- drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c index 740ee0d19582..d1f49caa5b13 100644 --- a/drivers/soc/fsl/dpio/qbman-portal.c +++ b/drivers/soc/fsl/dpio/qbman-portal.c @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) u32 mask_size; u32 eqcr_pi; - spin_lock_init(&p->access_spinlock); - if (!p) return NULL; + + spin_lock_init(&p->access_spinlock); + p->desc = d; p->mc.valid_bit = QB_VALID_BIT; p->sdq = 0; -- 2.25.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 9+ messages in thread
* RE: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check 2020-02-21 23:11 ` Colin King (?) @ 2020-02-21 23:18 ` Leo Li -1 siblings, 0 replies; 9+ messages in thread From: Leo Li @ 2020-02-21 23:18 UTC (permalink / raw) To: Colin King, Roy Pledge, Youri Querry, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQ29saW4gS2luZyA8Y29s aW4ua2luZ0BjYW5vbmljYWwuY29tPg0KPiBTZW50OiBGcmlkYXksIEZlYnJ1YXJ5IDIxLCAyMDIw IDU6MTIgUE0NCj4gVG86IFJveSBQbGVkZ2UgPHJveS5wbGVkZ2VAbnhwLmNvbT47IExlbyBMaSA8 bGVveWFuZy5saUBueHAuY29tPjsgWW91cmkNCj4gUXVlcnJ5IDx5b3VyaS5xdWVycnlfMUBueHAu Y29tP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wgMyBp bnNlcnRpb25zKCspLCAyIGRlbGV0aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL2RyaXZlcnMv c29jL2ZzbC9kcGlvL3FibWFuLXBvcnRhbC5jDQo+IGIvZHJpdmVycy9zb2MvZnNsL2RwaW8vcWJt YW4tcG9ydGFsLmMNCj4gaW5kZXggNzQwZWUwZDE5NTgyLi5kMWY0OWNhYTViMTMgMTAwNjQ0DQo+ IC0tLSBhL2RyaXZlcnMvc29jL2ZzbC9kcGlvL3FibWFuLXBvcnRhbC5jDQo+ICsrKyBiL2RyaXZl cnMvc29jL2ZzbC9kcGlvL3FibWFuLXBvcnRhbC5jDQo+IEBAIC0yNDksMTAgKzI0OSwxMSBAQCBz dHJ1Y3QgcWJtYW5fc3dwICpxYm1hbl9zd3BfaW5pdChjb25zdCBzdHJ1Y3QNCj4gcWJtYW5fc3dw X2Rlc2MgKmQpDQo+ICAJdTMyIG1hc2tfc2l6ZTsNCj4gIAl1MzIgZXFjcl9waTsNCj4gDQo+IC0J c3Bpbl9sb2NrX2luaXQoJnAtPmFjY2Vzc19zcGlubG9jayk7DQo+IC0NCj4gIAlpZiAoIXApDQo+ ICAJCXJldHVybiBOVUxMOw0KPiArDQo+ICsJc3Bpbl9sb2NrX2luaXQoJnAtPmFjY2Vzc19zcGlu bG9jayk7DQo+ICsNCj4gIAlwLT5kZXNjID0gZDsNCj4gIAlwLT5tYy52YWxpZF9iaXQgPSBRQl9W QUxJRF9CSVQ7DQo+ICAJcC0+c2RxID0gMDsNCj4gLS0NCj4gMi4yNS4wDQoNCg= ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check @ 2020-02-21 23:18 ` Leo Li 0 siblings, 0 replies; 9+ messages in thread From: Leo Li @ 2020-02-21 23:18 UTC (permalink / raw) To: Colin King, Roy Pledge, Youri Querry, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org > -----Original Message----- > From: Colin King <colin.king@canonical.com> > Sent: Friday, February 21, 2020 5:12 PM > To: Roy Pledge <roy.pledge@nxp.com>; Leo Li <leoyang.li@nxp.com>; Youri > Querry <youri.querry_1@nxp.com>; linuxppc-dev@lists.ozlabs.org; linux- > arm-kernel@lists.infradead.org > Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null > check > > From: Colin Ian King <colin.king@canonical.com> > > Pointer p is currently being dereferenced before it is null checked on a > memory allocation failure check. Fix this by checking if p is null before > dereferencing it. > > Addresses-Coverity: ("Dereference before null check") > Fixes: 3b2abda7d28c ("soc: fsl: dpio: Replace QMAN array mode with ring > mode enqueue") > Signed-off-by: Colin Ian King <colin.king@canonical.com> Applied for next. Thanks. > --- > drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c > b/drivers/soc/fsl/dpio/qbman-portal.c > index 740ee0d19582..d1f49caa5b13 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct > qbman_swp_desc *d) > u32 mask_size; > u32 eqcr_pi; > > - spin_lock_init(&p->access_spinlock); > - > if (!p) > return NULL; > + > + spin_lock_init(&p->access_spinlock); > + > p->desc = d; > p->mc.valid_bit = QB_VALID_BIT; > p->sdq = 0; > -- > 2.25.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check @ 2020-02-21 23:18 ` Leo Li 0 siblings, 0 replies; 9+ messages in thread From: Leo Li @ 2020-02-21 23:18 UTC (permalink / raw) To: Colin King, Roy Pledge, Youri Querry, linuxppc-dev@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org > -----Original Message----- > From: Colin King <colin.king@canonical.com> > Sent: Friday, February 21, 2020 5:12 PM > To: Roy Pledge <roy.pledge@nxp.com>; Leo Li <leoyang.li@nxp.com>; Youri > Querry <youri.querry_1@nxp.com>; linuxppc-dev@lists.ozlabs.org; linux- > arm-kernel@lists.infradead.org > Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null > check > > From: Colin Ian King <colin.king@canonical.com> > > Pointer p is currently being dereferenced before it is null checked on a > memory allocation failure check. Fix this by checking if p is null before > dereferencing it. > > Addresses-Coverity: ("Dereference before null check") > Fixes: 3b2abda7d28c ("soc: fsl: dpio: Replace QMAN array mode with ring > mode enqueue") > Signed-off-by: Colin Ian King <colin.king@canonical.com> Applied for next. Thanks. > --- > drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c > b/drivers/soc/fsl/dpio/qbman-portal.c > index 740ee0d19582..d1f49caa5b13 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct > qbman_swp_desc *d) > u32 mask_size; > u32 eqcr_pi; > > - spin_lock_init(&p->access_spinlock); > - > if (!p) > return NULL; > + > + spin_lock_init(&p->access_spinlock); > + > p->desc = d; > p->mc.valid_bit = QB_VALID_BIT; > p->sdq = 0; > -- > 2.25.0 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check 2020-02-21 23:11 ` Colin King (?) (?) @ 2020-02-24 6:35 ` Dan Carpenter -1 siblings, 0 replies; 9+ messages in thread From: Dan Carpenter @ 2020-02-24 6:35 UTC (permalink / raw) To: Colin King Cc: linux-kernel, Roy Pledge, kernel-janitors, Youri Querry, Li Yang, linuxppc-dev, linux-arm-kernel On Fri, Feb 21, 2020 at 11:11:43PM +0000, Colin King wrote: > --- > drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c > index 740ee0d19582..d1f49caa5b13 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) > u32 mask_size; > u32 eqcr_pi; > > - spin_lock_init(&p->access_spinlock); > - > if (!p) > return NULL; > + > + spin_lock_init(&p->access_spinlock); Allocations in the declaration blog are not super common in the kernel, but they're more bug prone. Generally, it's not beautiful to call a function which can fail in the allocation block. regards, dan carpenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check @ 2020-02-24 6:35 ` Dan Carpenter 0 siblings, 0 replies; 9+ messages in thread From: Dan Carpenter @ 2020-02-24 6:35 UTC (permalink / raw) To: Colin King Cc: Roy Pledge, Li Yang, Youri Querry, linuxppc-dev, linux-arm-kernel, kernel-janitors, linux-kernel On Fri, Feb 21, 2020 at 11:11:43PM +0000, Colin King wrote: > --- > drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c > index 740ee0d19582..d1f49caa5b13 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) > u32 mask_size; > u32 eqcr_pi; > > - spin_lock_init(&p->access_spinlock); > - > if (!p) > return NULL; > + > + spin_lock_init(&p->access_spinlock); Allocations in the declaration blog are not super common in the kernel, but they're more bug prone. Generally, it's not beautiful to call a function which can fail in the allocation block. regards, dan carpenter ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check @ 2020-02-24 6:35 ` Dan Carpenter 0 siblings, 0 replies; 9+ messages in thread From: Dan Carpenter @ 2020-02-24 6:35 UTC (permalink / raw) To: Colin King Cc: linux-kernel, Roy Pledge, kernel-janitors, Youri Querry, Li Yang, linuxppc-dev, linux-arm-kernel On Fri, Feb 21, 2020 at 11:11:43PM +0000, Colin King wrote: > --- > drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c > index 740ee0d19582..d1f49caa5b13 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) > u32 mask_size; > u32 eqcr_pi; > > - spin_lock_init(&p->access_spinlock); > - > if (!p) > return NULL; > + > + spin_lock_init(&p->access_spinlock); Allocations in the declaration blog are not super common in the kernel, but they're more bug prone. Generally, it's not beautiful to call a function which can fail in the allocation block. regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check @ 2020-02-24 6:35 ` Dan Carpenter 0 siblings, 0 replies; 9+ messages in thread From: Dan Carpenter @ 2020-02-24 6:35 UTC (permalink / raw) To: Colin King Cc: linux-kernel, Roy Pledge, kernel-janitors, Youri Querry, Li Yang, linuxppc-dev, linux-arm-kernel On Fri, Feb 21, 2020 at 11:11:43PM +0000, Colin King wrote: > --- > drivers/soc/fsl/dpio/qbman-portal.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c > index 740ee0d19582..d1f49caa5b13 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -249,10 +249,11 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d) > u32 mask_size; > u32 eqcr_pi; > > - spin_lock_init(&p->access_spinlock); > - > if (!p) > return NULL; > + > + spin_lock_init(&p->access_spinlock); Allocations in the declaration blog are not super common in the kernel, but they're more bug prone. Generally, it's not beautiful to call a function which can fail in the allocation block. regards, dan carpenter ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2020-02-24 9:28 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-02-21 23:11 [PATCH][next] soc: fsl: dpio: fix dereference of pointer p before null check Colin King 2020-02-21 23:11 ` Colin King 2020-02-21 23:18 ` Leo Li 2020-02-21 23:18 ` Leo Li 2020-02-21 23:18 ` Leo Li 2020-02-24 6:35 ` Dan Carpenter 2020-02-24 6:35 ` Dan Carpenter 2020-02-24 6:35 ` Dan Carpenter 2020-02-24 6:35 ` Dan Carpenter
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.