Message ID | 20170908103440.junitv63lrzc5ih5@mwanda (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Hi, On 9/8/2017 4:04 PM, Dan Carpenter wrote: > We need to free "intent" and "intent->data" on a couple error paths. > > Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> > > diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c > index fecb1dafa8f3..5dcc9bf1c5bc 100644 > --- a/drivers/rpmsg/qcom_glink_native.c > +++ b/drivers/rpmsg/qcom_glink_native.c > @@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, > unsigned long flags; > > intent = kzalloc(sizeof(*intent), GFP_KERNEL); > - > if (!intent) > return NULL; > > intent->data = kzalloc(size, GFP_KERNEL); > if (!intent->data) > - return NULL; > + goto free_intent; > > spin_lock_irqsave(&channel->intent_lock, flags); > ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC); > if (ret < 0) { > spin_unlock_irqrestore(&channel->intent_lock, flags); > - return NULL; > + goto free_data; > } > spin_unlock_irqrestore(&channel->intent_lock, flags); > > @@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, > intent->reuse = reuseable; > > return intent; > + > +free_data: > + kfree(intent->data); > +free_intent: > + kfree(intent); > + return NULL; Acked-by: Sricharan R <sricharan@codeaurora.org> Regards, Sricharan
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index fecb1dafa8f3..5dcc9bf1c5bc 100644 --- a/drivers/rpmsg/qcom_glink_native.c +++ b/drivers/rpmsg/qcom_glink_native.c @@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, unsigned long flags; intent = kzalloc(sizeof(*intent), GFP_KERNEL); - if (!intent) return NULL; intent->data = kzalloc(size, GFP_KERNEL); if (!intent->data) - return NULL; + goto free_intent; spin_lock_irqsave(&channel->intent_lock, flags); ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC); if (ret < 0) { spin_unlock_irqrestore(&channel->intent_lock, flags); - return NULL; + goto free_data; } spin_unlock_irqrestore(&channel->intent_lock, flags); @@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, intent->reuse = reuseable; return intent; + +free_data: + kfree(intent->data); +free_intent: + kfree(intent); + return NULL; } static void qcom_glink_handle_rx_done(struct qcom_glink *glink,
We need to free "intent" and "intent->data" on a couple error paths. Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> -- To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html