* [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference
@ 2014-12-14 22:37 Rickard Strandqvist
2014-12-15 10:25 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-12-14 22:37 UTC (permalink / raw)
To: Oleg Drokin, Andreas Dilger
Cc: Rickard Strandqvist, Greg Kroah-Hartman, Greg Donald,
Brilliantov Kirill Vladimirovich, HPDD-discuss, devel,
linux-kernel
There is otherwise a risk of a possible null pointer dereference.
Was largely found by using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 9f719bc..9ba6293 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -237,13 +237,15 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buff
size_t count, loff_t *off)
{
struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- struct client_obd *cli = &obd->u.cli;
+ struct client_obd *cli;
int rc;
__u64 val;
if (obd == NULL)
return 0;
+ cli = &obd->u.cli;
+
rc = lprocfs_write_u64_helper(buffer, count, &val);
if (rc)
return rc;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference
2014-12-14 22:37 [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference Rickard Strandqvist
@ 2014-12-15 10:25 ` Dan Carpenter
2014-12-15 23:07 ` Rickard Strandqvist
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2014-12-15 10:25 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Oleg Drokin, Andreas Dilger, devel, Greg Kroah-Hartman,
Brilliantov Kirill Vladimirovich, linux-kernel, HPDD-discuss,
Greg Donald
On Sun, Dec 14, 2014 at 11:37:18PM +0100, Rickard Strandqvist wrote:
> There is otherwise a risk of a possible null pointer dereference.
>
> Was largely found by using a static code analysis program called cppcheck.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
> index 9f719bc..9ba6293 100644
> --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
> +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
> @@ -237,13 +237,15 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buff
> size_t count, loff_t *off)
> {
> struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
> - struct client_obd *cli = &obd->u.cli;
> + struct client_obd *cli;
This isn't really a dereference. You're just getting the address of
obd->u.cli. So if obd is NULL then it won't crash.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference
2014-12-15 10:25 ` Dan Carpenter
@ 2014-12-15 23:07 ` Rickard Strandqvist
2014-12-16 9:26 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-12-15 23:07 UTC (permalink / raw)
To: Dan Carpenter
Cc: Oleg Drokin, Andreas Dilger, devel, Greg Kroah-Hartman,
Brilliantov Kirill Vladimirovich, linux-kernel@vger.kernel.org,
HPDD-discuss, Greg Donald
Hi Dan
Quite right! Had to try it.
Do nothing then?
But you must agree that it is still ugly and confusing code.
Kind regards
Rickard Strandqvist
2014-12-15 11:25 GMT+01:00 Dan Carpenter <dan.carpenter@oracle.com>:
> On Sun, Dec 14, 2014 at 11:37:18PM +0100, Rickard Strandqvist wrote:
>> There is otherwise a risk of a possible null pointer dereference.
>>
>> Was largely found by using a static code analysis program called cppcheck.
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>> drivers/staging/lustre/lustre/osc/lproc_osc.c | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
>> index 9f719bc..9ba6293 100644
>> --- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
>> +++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
>> @@ -237,13 +237,15 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file, const char *buff
>> size_t count, loff_t *off)
>> {
>> struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
>> - struct client_obd *cli = &obd->u.cli;
>> + struct client_obd *cli;
>
> This isn't really a dereference. You're just getting the address of
> obd->u.cli. So if obd is NULL then it won't crash.
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference
2014-12-15 23:07 ` Rickard Strandqvist
@ 2014-12-16 9:26 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2014-12-16 9:26 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: devel, Andreas Dilger, Greg Kroah-Hartman,
Brilliantov Kirill Vladimirovich, linux-kernel@vger.kernel.org,
Oleg Drokin, Greg Donald, HPDD-discuss
On Tue, Dec 16, 2014 at 12:07:19AM +0100, Rickard Strandqvist wrote:
> Hi Dan
>
> Quite right! Had to try it.
>
> Do nothing then?
> But you must agree that it is still ugly and confusing code.
>
Yes. I agree that it's confusing. I also suspect that "obd" is never
NULL but I haven't actually looked and these things are sometimes
complicated to verify.
I fine with merging the patch as a cleanup.
Smatch has code to not warn about these but it's not 100% correct so
it still warns sometimes when it shouldn't.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-16 9:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-14 22:37 [PATCH] staging: lustre: lustre: osc: lproc_osc.c: Fix for possible null pointer dereference Rickard Strandqvist
2014-12-15 10:25 ` Dan Carpenter
2014-12-15 23:07 ` Rickard Strandqvist
2014-12-16 9:26 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox