Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1705490 > unrolled thread
| Started by | Santosh Mardi <gsantosh@codeaurora.org> |
|---|---|
| First post | 2017-08-07 15:10 +0200 |
| Last post | 2017-08-08 21:30 +0200 |
| Articles | 5 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH] devfreq: add error check for sscanf in userspace governor Santosh Mardi <gsantosh@codeaurora.org> - 2017-08-07 15:10 +0200
RE: [PATCH] devfreq: add error check for sscanf in userspace governor MyungJoo Ham <myungjoo.ham@samsung.com> - 2017-08-08 02:20 +0200
Re: [PATCH] devfreq: add error check for sscanf in userspace governor Chanwoo Choi <cw00.choi@samsung.com> - 2017-08-08 03:00 +0200
Re: [PATCH] devfreq: add error check for sscanf in userspace governor Pavan Kondeti <pkondeti@codeaurora.org> - 2017-08-08 09:00 +0200
Re: [PATCH] devfreq: add error check for sscanf in userspace governor Saravana Kannan <skannan@codeaurora.org> - 2017-08-08 21:30 +0200
| From | Santosh Mardi <gsantosh@codeaurora.org> |
|---|---|
| Date | 2017-08-07 15:10 +0200 |
| Subject | [PATCH] devfreq: add error check for sscanf in userspace governor |
| Message-ID | <ubPXd-bV-43@gated-at.bofh.it> |
store_freq function of devfreq userspace governor executes further, even if error is returned from sscanf, this will result in setting up wrong frequency value. Add proper error check to bail out if any error is returned. Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org> --- drivers/devfreq/governor_userspace.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c index 77028c2..1d0c9cc 100644 --- a/drivers/devfreq/governor_userspace.c +++ b/drivers/devfreq/governor_userspace.c @@ -53,12 +53,15 @@ static ssize_t store_freq(struct device *dev, struct device_attribute *attr, mutex_lock(&devfreq->lock); data = devfreq->data; - sscanf(buf, "%lu", &wanted); + err = sscanf(buf, "%lu", &wanted); + if (err != 1) + goto out; data->user_frequency = wanted; data->valid = true; err = update_devfreq(devfreq); if (err == 0) err = count; +out: mutex_unlock(&devfreq->lock); return err; } -- 1.9.1
[toc] | [next] | [standalone]
| From | MyungJoo Ham <myungjoo.ham@samsung.com> |
|---|---|
| Date | 2017-08-08 02:20 +0200 |
| Subject | RE: [PATCH] devfreq: add error check for sscanf in userspace governor |
| Message-ID | <uc0pB-7WI-13@gated-at.bofh.it> |
| In reply to | #1705490 |
> store_freq function of devfreq userspace governor > executes further, even if error is returned from sscanf, > this will result in setting up wrong frequency value. > > Add proper error check to bail out if any error is returned. > > Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org> Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com> > --- > drivers/devfreq/governor_userspace.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-)
[toc] | [prev] | [next] | [standalone]
| From | Chanwoo Choi <cw00.choi@samsung.com> |
|---|---|
| Date | 2017-08-08 03:00 +0200 |
| Subject | Re: [PATCH] devfreq: add error check for sscanf in userspace governor |
| Message-ID | <uc12h-8bw-9@gated-at.bofh.it> |
| In reply to | #1705490 |
Hi, On 2017년 08월 07일 22:06, Santosh Mardi wrote: > store_freq function of devfreq userspace governor > executes further, even if error is returned from sscanf, > this will result in setting up wrong frequency value. > > Add proper error check to bail out if any error is returned. > > Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org> > --- > drivers/devfreq/governor_userspace.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c > index 77028c2..1d0c9cc 100644 > --- a/drivers/devfreq/governor_userspace.c > +++ b/drivers/devfreq/governor_userspace.c > @@ -53,12 +53,15 @@ static ssize_t store_freq(struct device *dev, struct device_attribute *attr, > mutex_lock(&devfreq->lock); > data = devfreq->data; > > - sscanf(buf, "%lu", &wanted); > + err = sscanf(buf, "%lu", &wanted); > + if (err != 1) > + goto out; > data->user_frequency = wanted; > data->valid = true; > err = update_devfreq(devfreq); > if (err == 0) > err = count; > +out: > mutex_unlock(&devfreq->lock); > return err; > } > Looks good to me. Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com> -- Best Regards, Chanwoo Choi Samsung Electronics
[toc] | [prev] | [next] | [standalone]
| From | Pavan Kondeti <pkondeti@codeaurora.org> |
|---|---|
| Date | 2017-08-08 09:00 +0200 |
| Message-ID | <uc6EH-4gz-25@gated-at.bofh.it> |
| In reply to | #1705490 |
Hi Santosh, On Mon, Aug 7, 2017 at 6:36 PM, Santosh Mardi <gsantosh@codeaurora.org> wrote: > store_freq function of devfreq userspace governor > executes further, even if error is returned from sscanf, > this will result in setting up wrong frequency value. > > Add proper error check to bail out if any error is returned. > > Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org> > --- > drivers/devfreq/governor_userspace.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c > index 77028c2..1d0c9cc 100644 > --- a/drivers/devfreq/governor_userspace.c > +++ b/drivers/devfreq/governor_userspace.c > @@ -53,12 +53,15 @@ static ssize_t store_freq(struct device *dev, struct device_attribute *attr, > mutex_lock(&devfreq->lock); > data = devfreq->data; > > - sscanf(buf, "%lu", &wanted); > + err = sscanf(buf, "%lu", &wanted); > + if (err != 1) > + goto out; You can save this goto statement by moving this sscanf checking to before taking the mutex. > data->user_frequency = wanted; > data->valid = true; > err = update_devfreq(devfreq); > if (err == 0) > err = count; > +out: > mutex_unlock(&devfreq->lock); > return err; > } > -- > 1.9.1 > -- Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
[toc] | [prev] | [next] | [standalone]
| From | Saravana Kannan <skannan@codeaurora.org> |
|---|---|
| Date | 2017-08-08 21:30 +0200 |
| Message-ID | <ucimt-4kC-15@gated-at.bofh.it> |
| In reply to | #1706079 |
On 08/07/2017 11:56 PM, Pavan Kondeti wrote: > Hi Santosh, > > On Mon, Aug 7, 2017 at 6:36 PM, Santosh Mardi <gsantosh@codeaurora.org> wrote: >> store_freq function of devfreq userspace governor >> executes further, even if error is returned from sscanf, >> this will result in setting up wrong frequency value. >> >> Add proper error check to bail out if any error is returned. >> >> Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org> >> --- >> drivers/devfreq/governor_userspace.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/devfreq/governor_userspace.c b/drivers/devfreq/governor_userspace.c >> index 77028c2..1d0c9cc 100644 >> --- a/drivers/devfreq/governor_userspace.c >> +++ b/drivers/devfreq/governor_userspace.c >> @@ -53,12 +53,15 @@ static ssize_t store_freq(struct device *dev, struct device_attribute *attr, >> mutex_lock(&devfreq->lock); >> data = devfreq->data; >> >> - sscanf(buf, "%lu", &wanted); >> + err = sscanf(buf, "%lu", &wanted); Also, we could just use kstroul(). >> + if (err != 1) >> + goto out; > > You can save this goto statement by moving this sscanf checking to > before taking the mutex. > >> data->user_frequency = wanted; >> data->valid = true; >> err = update_devfreq(devfreq); >> if (err == 0) >> err = count; >> +out: >> mutex_unlock(&devfreq->lock); >> return err; >> } >> -- >> 1.9.1 >> -Saravana -- Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web